note 56428 added to function.str-replace
| From: | dominicshaw at hotmail dot com | Date: | Fri, 02 Sep 2005 08:38:01 +0000 |
| Subject: | note 56428 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-94642@lists.php.net to get a copy of this message | ||
I have been trying to make a single quote be sent through to my database backend, but even when I
replace the single quote with two single quotes, it wouldn't work properly.
After some fiddling I made this code:
$strSQL = $strSQL.'spAppTitle = "'.str_replace("'",
"''", $strAppTitle).'"';
$strSQL = str_replace("\\", "", $strSQL);
$q_ud = mysql_query($strSQL) or die("SQL Error: <p>SQL:
$strSQL</p>".mysql_error());
Which allows me to send values to the database with a single quote, with no backpaces infront of it.
Hope this helps someone.
----
Manual Page -- http://www.php.net/manual/en/function.str-replace.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+56428
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56428&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56428&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56428&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56428&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56428&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56428&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+56428&report=yes
Search -- http://master.php.net/manage/user-notes.php