RE: [PHP-WIN] ODBC: SQL insert problem
| From: | Asendorf, John | Date: | Wed, 11 Oct 2000 13:15:24 +0000 |
| Subject: | RE: [PHP-WIN] ODBC: SQL insert problem | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-3151@lists.php.net to get a copy of this message | ||
I think Andy Hoffman came up with these...
//two functions for ' and " problems
function AccessAddSlashes($S) {
$S=str_replace("\\'","''",$S);
$S=str_replace("\\\"","\"\"",$S);
return $S;
}
function AccessStripSlashes($S) {
$S=str_replace("\"\"","\\\"",$S);
$S=stripslashes($S);
return $S;
}
$comment = AccessAddSlashes($comment);
then when getting it back out, you use the AddSlashes
---------------------
John Asendorf - jasendorf@lcounty.com
Web Applications Developer
http://www.lcounty.com - NEW FEATURES ADDED DAILY!
Licking County, Ohio, USA
740-349-3631
> -----Original Message-----
> From: Warwick Chapman (Budgee) [mailto:Budgee@ghs.kzn.school.za]
> Sent: Wednesday, October 11, 2000 9:08 AM
> To: Asendorf, John
> Cc: php-windows@lists.php.net
> Subject: RE: [PHP-WIN] ODBC: SQL insert problem
>
>
> Thanks - works fine.
>
> I have a problem with the text area section...
>
> If a ' comes up in the text area, the insert bombs out with the
> following message:
>
> Thanks
>
> <?
> $conn=odbc_connect("glenwood","","");
>
> if ($submit) {
> $sql="insert into headmaster (title, [date], comment) values
> ('$title', '$date', '$comment')";
> $result = odbc_exec($conn,$sql);
> } else {
> ?>
>
> <form method="post" action="<?echo $PHP_SELF;?>">
> <table>
> <tr><td>Title: </td><td><input type="text"
> name="title"
> size="40"></td></tr>
> <tr><td>Date: </td><td><input type="text"
> name="date">
> MM/DD/YY</td></tr>
> <tr><td> </td><td><textarea name="comment"
> cols="50"
> rows="10"></textarea></tr>
> <tr><td><input type="submit"
> name="submit"></td></tr>
> </tr>
> </table>
> </form>
>
> <?
> }
> odbc_close ($conn);
> ?>
>
> Cheers
>
> Warwick Chapman (1999)
> Assistant IT Manager
> Glenwood High School, Durban, South Africa
> 031 2055241
> 083 7797094
> www.glenwoodhighschool.co.za
>