note 20431 deleted from function.addslashes by philip
| From: | philip@php.net | Date: | Tue, 20 Jul 2004 17:20:09 +0000 |
| Subject: | note 20431 deleted from function.addslashes by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-73714@lists.php.net to get a copy of this message | ||
Note Submitter: nik@robertanthony.com
----
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);