Re: mysql_escape_string breaks EOL?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David Robley wrote:
It seems that mysql_escape_string and mysql_real_escape_string do
undesirable things to EOL markers - data from textareas escaped with either
of those functions is entered, and retrieved with, the characters /r/n
instead of a true line break.

This snippet of code demonstrates the problem:

<?php
$wibble = "\"This\" and\n'that'";
echo "Before: $wibble<BR>\n";
$wibble1 = addslashes($wibble);
echo "Addslashes: $wibble1<BR>\n";
$wibble2 = mysql_escape_string($wibble);
echo "Escape: $wibble2<BR>\n";
?>

And the output (from Show source) with line breaks exactly as in the source

Before: "This" and
'that'<BR>
Addslashes: \"This\" and
\'that\'<BR>
Escape: \"This\" and\n\'that\'<BR>

Is this a bug, or am I totally missing something?

No, it's not a bug. If you use it in mysql query, mysql server will convert \n to newline character


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux