note 66890 deleted from function.mysql-real-escape-string by nlopess
| From: | nlopess@php.net | Date: | Wed, 31 May 2006 17:35:35 +0000 |
| Subject: | note 66890 deleted from function.mysql-real-escape-string by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-112660@lists.php.net to get a copy of this message | ||
Note Submitter: spiritual-coder at spiritual-coder dot com
----
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