thefollower Posted October 23, 2008 Share Posted October 23, 2008 I have tried so many functions yet every time i send a message which has the ' symbol it becomes \' And its very frustrating.. i have this: $POST['letter'] = "Can't do this"; <?php $Message = mysql_real_escape_string(stripslashes(nl2br(strip_tags($_POST['letter'])))); // Send the email. $subject = "Login Infomation Desk"; $headers = 'From: Server'; $message = "A username ".$Username." has requested help !\r \r ~------------------~ \r \r"; $message = $message. "Their message is: \r \r ".$Message." \r \r ~------------------~ \r \r"; $message = $message. " \r Username is: ".$Username." \r"; $message = $message. " \r Email is: ".$Email; mail('myemail here', $subject, $message, $headers); ?> My email shows: Can/'t do this! What function do i need to make it come out correctly? Quote Link to comment Share on other sites More sharing options...
realjumper Posted October 23, 2008 Share Posted October 23, 2008 $message = stripslashes($message); Quote Link to comment Share on other sites More sharing options...
thefollower Posted October 23, 2008 Author Share Posted October 23, 2008 stripslashes function is already in there =/ Quote Link to comment Share on other sites More sharing options...
realjumper Posted October 23, 2008 Share Posted October 23, 2008 stripslashes function is already in there =/ So it is...sorry. Personally I would do it like this, but I don't know if this will help you. <?php $letter = mysql_real_escape_string(stripslashes(nl2br(strip_tags($_POST['letter'])))); // Send the email. $subject = "Login Infomation Desk"; $headers = 'From: Server'; $message = "A username ".$Username." has requested help !\r \r ~------------------~ \r \r"; $message = $message. "Their message is: \r \r ".$letter." \r \r ~------------------~ \r \r"; $message = $message. " \r Username is: ".$Username." \r"; $message = $message. " \r Email is: ".$Email; mail('myemail here', $subject, $message, $headers); ?> Quote Link to comment Share on other sites More sharing options...
thefollower Posted October 23, 2008 Author Share Posted October 23, 2008 Renamed a variable? That doesn't really make a difference to the issue involved. Quote Link to comment Share on other sites More sharing options...
aeonsky Posted October 23, 2008 Share Posted October 23, 2008 Here is what your doing... $message = "My name\'s Jon"; stripslashes($message); //Produces "My name's Jon"; mysql_real_ecape_string($message); //Produces "My name\'s Jon"; Mysql_real_escape_string(); is the problem. You are escaping characters again, after removing the slashes. Quote Link to comment Share on other sites More sharing options...
realjumper Posted October 23, 2008 Share Posted October 23, 2008 Okay, well....I see you have renamed 'letter' to 'Message', and 'message' is already part of the mail function. Just trying out different things, what do you have to lose? Quote Link to comment Share on other sites More sharing options...
thefollower Posted October 23, 2008 Author Share Posted October 23, 2008 Here is what your doing... $message = "My name\'s Jon"; stripslashes($message); //Produces "My name's Jon"; mysql_real_ecape_string($message); //Produces "My name\'s Jon"; Mysql_real_escape_string(); is the problem. You are escaping characters again, after removing the slashes. But logically the mysql_real_escape_string is before the stripslashes.. not after.. i already thought of that Quote Link to comment Share on other sites More sharing options...
aeonsky Posted October 23, 2008 Share Posted October 23, 2008 $Message = mysql_real_escape_string(stripslashes(nl2br(strip_tags($_POST['letter'])))); That is your code. First you strip_tags, then nl2br, then stripslahes and then after you are escaping it again. What is the point of that? You are first removing slashes and then adding them again. You read from the inside-to-out, like math functions. Quote Link to comment Share on other sites More sharing options...
rhodesa Posted October 23, 2008 Share Posted October 23, 2008 functions execute from the inside out, so mysql_real_escape_string happens last. but also, you aren't inserting it into a DB, so there is no need to escape it. remove mysql_real_escape_string and you should be good to go p.s. - the content type of your email is plain text anyways, so why do you do nl2br? Quote Link to comment Share on other sites More sharing options...
thefollower Posted October 23, 2008 Author Share Posted October 23, 2008 functions execute from the inside out, so mysql_real_escape_string happens last. but also, you aren't inserting it into a DB, so there is no need to escape it. remove mysql_real_escape_string and you should be good to go p.s. - the content type of your email is plain text anyways, so why do you do nl2br? I see i didn't know that functions worked backwards... also I have nl2br because I was about to ask how to make emails with nice formats and stuff... can't find a tutorial on how to do it anywhere with google. I got mysql_real_escape_string there just from sheer habit...lol! Thanks for the tip off. Quote Link to comment Share on other sites More sharing options...
rhodesa Posted October 23, 2008 Share Posted October 23, 2008 <?php $letter = nl2br(strip_tags(stripslashes($_POST['letter']))); // Send the email. $subject = "Login Infomation Desk"; $headers = "From: Server\r\n"; $headers .= "Content-type: text/html;\r\n"; $message = "A username $Username has requested help !<br /><hr>"; $message .= "Their message is: <br /> $letter <br />"; $message .= "Username is: $Username <br />"; $message .= "Email is: $Email "; mail('myemail here', $subject, $message, $headers); ?> Quote Link to comment Share on other sites More sharing options...
thefollower Posted October 23, 2008 Author Share Posted October 23, 2008 Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.