Jump to content

Recommended Posts

I am using a html form to POST to a php page

 

on the php page I do this:

$rawtext = $_POST['field'];
$findlinebreak = strstr($rawtext, "\r\n");
        if ($findlinebreak != FALSE) {
        echo 'found a \r\n line break in the raw posted data!<br>';
        }
$escapedtext = mysql_escape_string($rawtext);

$rawtext = nl2br($rawtext);
echo "this is the rawtext with nl2br: $rawtext \n";

$escapetext = nl2br($escapedtext);
echo "this is the escapedtext with nl2br: $escapedtext \n";

 

 

it returns this:

 

found a \r\n line break in raw posted data!

this is the rawtext with nl2br: (this one outputs line breaks)

this one is the escapedtext with nl2br (this one does not output line breaks)

 

 

I wrote the above to help you understand my methods in trying to figure this out, but basically the problem is simple, if I mysql_escape_string() a string it messes up the \r\n line breaks...

Why? and How can I fix it?

 

 

 

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.