note 104354 added to function.mysql-real-escape-string

From: Date: Fri, 10 Jun 2011 11:14:28 +0000
Subject: note 104354 added to function.mysql-real-escape-string
Groups: php.notes 
Request: Send a blank email to php-notes+get-180402@lists.php.net to get a copy of this message
a detail to be added to the function reverse_escape of m-t at live dot fr (17-Oct-2010 04:30) I used your function and it works fine, except when I was including " and had to later present the content of the db field in a web page: anything after the fisrt " was not presented, so I found a solution that works also in this case, substituting the straight double quotes with the oblique double quotes. I re-write the function here: Original function: function reverse_escape($str) { $search=array("\\\\","\\0","\\n","\\r","\Z","\'",'\"'); $replace=array("\\","\0","\n","\r","\x1a","'",'"'); return str_replace($search,$replace,$str); } New function: function resc($txt){ $search=array("\\\\","\\0","\\n","\\r","\Z","\'",'\"'); $replace=array("\\","\0","\n","\r","\x1a","'",'“'); return str_replace($search,$replace,$txt); } I hope it can help someone. Best regards to all ---- Server IP: 69.147.83.197 Probable Submitter: 151.20.159.252 ---- Manual Page -- http://www.php.net/manual/en/function.mysql-real-escape-string.php Edit -- https://master.php.net/note/edit/104354 Del: integrated -- https://master.php.net/note/delete/104354/integrated Del: useless -- https://master.php.net/note/delete/104354/useless Del: bad code -- https://master.php.net/note/delete/104354/bad+code Del: spam -- https://master.php.net/note/delete/104354/spam Del: non-english -- https://master.php.net/note/delete/104354/non-english Del: in docs -- https://master.php.net/note/delete/104354/in+docs Del: other reasons-- https://master.php.net/note/delete/104354 Reject -- https://master.php.net/note/reject/104354 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#180402) next »