note 20431 added to function.addslashes
| From: | nik at robertanthony dot com | Date: | Wed, 03 Apr 2002 17:55:47 +0000 |
| Subject: | note 20431 added to function.addslashes | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-28548@lists.php.net to get a copy of this message | ||
addslashes does not work in Access for inserting fields that contain single quotes or apostrophes.
For Example:
$fieldOne = "Eat At Joe's";
$fieldTwo = "Delectable Dining at Fabulous Fares";
$query = "INSERT INTO Table (fieldOne,fieldTwo)
VALUES ('$fieldOne','$fieldTwo')";
Returns a syntax error. This can be fixed by using a regular expression to replace the single quote
with the ` character (on a QWERTY keyboard -- above the TAB). You can always replace it back when
outputting the information, but it still looks similar and will be recognizable to users who are not
familiar with your replacement reasoning.
Example (place before the $query statement):
$fieldOne = ereg_replace("\'","`",$fieldOne);
--
http://www.php.net/manual/en/function.addslashes.php
http://master.php.net/manage/user-notes.php?action=edit+20431
http://master.php.net/manage/user-notes.php?action=delete+20431
http://master.php.net/manage/user-notes.php?action=reject+20431