note 11223 added to str_replace
| From: | dwight at wwwalker dot com dot au | Date: | Sun, 11 Feb 2001 05:27:41 +0000 |
| Subject: | note 11223 added to str_replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-10896@lists.php.net to get a copy of this message | ||
It inserts a backslash for you - weird sideeffect if you are doing mysql inserts - stuffs up inserts
if you use:
$fieldname = "18' doughboy pool";
str_replace ("'", "''", $fieldname); /* two ' marks */
-> $fieldname = "18\'' doughboy pool";
which breaks INSERT in mysql
Here is what works:
$fieldname = "18' doughboy pool";
str_replace("'", "'", $fieldname); /* one ' mark */
-> $fieldname = "18\' doughboy pool";
http://www.php.net/manual/en/function.str-replace.php