note 70078 added to function.mssql-query
| From: | vollmer at ampache dot org | Date: | Mon, 02 Oct 2006 15:52:02 +0000 |
| Subject: | note 70078 added to function.mssql-query | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-117944@lists.php.net to get a copy of this message | ||
As noted above you need to escape ' with '' in mssql, however while doing a large
dataset migration I ran into an issue with \0 (NULL) in the strings breaking the query. I ended up
writting the below small little function, I'm sure it could be done faster/better but it has
served me well.
function sqlEscape($sql) {
/* De MagicQuotes */
$fix_str = stripslashes($sql);
$fix_str = str_replace("'","''",$sql);
$fix_str = str_replace("\0","[NULL]",$fix_str);
return $fix_str;
} // sqlEscape
----
Server IP: 140.211.166.146
Probable Submitter: 128.193.183.115
----
Manual Page -- http://www.php.net/manual/en/function.mssql-query.php
Edit -- https://master.php.net/note/edit/70078
Del: integrated -- https://master.php.net/note/delete/70078/integrated
Del: useless -- https://master.php.net/note/delete/70078/useless
Del: bad code -- https://master.php.net/note/delete/70078/bad+code
Del: spam -- https://master.php.net/note/delete/70078/spam
Del: non-english -- https://master.php.net/note/delete/70078/non-english
Del: in docs -- https://master.php.net/note/delete/70078/in+docs
Del: other reasons-- https://master.php.net/note/delete/70078
Reject -- https://master.php.net/note/reject/70078
Search -- https://master.php.net/manage/user-notes.php