Jump to content

[SOLVED] mysql_real_escape_string() and nl2br() problem


shadiadiph

Recommended Posts

I am inserting a message to a database but at the same time sending it by email.

 

the test message i am using is .

 


line's one's

line's two's

 

problem i have is i am using mysql_real_escape_string($message) to insert it to the database.

 

then when i print $message it says line\'s one\'s\r\n\r\nline\'s two\'s

 

then if i use $message= stripslashes($message) then $message= nl2br($message)

 

it returns 'sline's one'srnrnline's two's 

 

it doesn't break the line and prints rnrn???

Link to comment
Share on other sites

samshel that kind of works it breaks the lines by doing that but still has the rnrn.

 

darkwater the problem is not inserting it to the datbase it is inserting to the database fine and when i call it it looks fine the problem is in the email that is sent this is where rn is appering before i wasn't using mysql_escape_string and it was working fine but i am told that you have to use it :(

Link to comment
Share on other sites

ok guys thatks for the input i solved just had to change the order a bit.

 

$message      = stripslashes($_POST["message"]);
$message2     = ($message);
$message      = mysql_real_escape_string($message);

 

then insert $message to the database

 

then

 

$message2     = nl2br($message2);

 

before insering $message2 into the email

Link to comment
Share on other sites

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.