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

From: Date: Wed, 31 May 2006 15:05:07 +0000
Subject: note 66890 added to function.mysql-real-escape-string
Groups: php.notes 
Request: Send a blank email to php-notes+get-112653@lists.php.net to get a copy of this message
I had a problem with newline-characters ("\\n" & "\\r") being converted to their literal representation ('\\n' & '\\r') giving unwanted output after fields were converted. To solve this problem I simply replace the literals again after conversion: <? // ... $field = mysql_real_escape_string($field); $field = str_replace('\\r', "\\r", $field); $field = str_replace('\\n', "\\n", $field); $query = "INSERT INTO foo (bar) VALUES ('".$field."'"); mysql_query($query); ?> Greetz, Sébastien Jacobs http://www.spiritual-coder.com ---- Server IP: 216.194.113.175 Probable Submitter: 80.201.8.187 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.mysql-real-escape-string.php Edit -- http://master.php.net/note/edit/66890 Del: integrated -- http://master.php.net/note/delete/66890/integrated Del: useless -- http://master.php.net/note/delete/66890/useless Del: bad code -- http://master.php.net/note/delete/66890/bad+code Del: spam -- http://master.php.net/note/delete/66890/spam Del: non-english -- http://master.php.net/note/delete/66890/non-english Del: in docs -- http://master.php.net/note/delete/66890/in+docs Del: other reasons-- http://master.php.net/note/delete/66890 Reject -- http://master.php.net/note/reject/66890 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#112653) next »