PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Can anyone tell me why my code still sends me \r\n in my html emails or point me to a reference in how to format my code properly so that I don't get horrible emails.
So what does $_POST['myReply'] look like before you try to send it? Var_dump() it and before you pass it to nl2br and after and you might see the problem.
This is what I am attempting to do:
1. I have to capture the text from the form textarea
2. Insert it into a DB
3. mail the text to a recipient
Okay so this is what I have found:
1. I cannot use nl2br or even str_replace to create the lines if I have done my sql prep first
2. If I send it first and then do the mysql_prep it changes the text and the second recipient gets the \r\n
Here is what the first recipient sees:
/////////////////
This is my testing
Here is line 1
Here is line 2
There was a line skipped
//////////////
This is what the second recipient sees:
////////////
This is my testing
Here is line 1\r\nHere is line 2\r\n\r\nThere was a line skipped
//////////////
The code for mysql_prep is below
Question: How can I reverse this each time considering I have to send this text to multiple recipients in a while loop?
CODE FOR MYSQL_PREP
$magic_quotes_active = get_magic_quotes_gpc();
$new_enough_php = function_exists( "mysql_real_escape_string" ); // i.e. PHP >= v4.3.0
if( $new_enough_php ) { // PHP v4.3.0 or higher
// undo any magic quote effects so mysql_real_escape_string can do the work
if( $magic_quotes_active ) { $value = stripslashes( $value ); }
$value = mysql_real_escape_string( $value );
} else { // before PHP v4.3.0
// if magic quotes aren't already on then add slashes manually
if( !$magic_quotes_active ) { $value = addslashes( $value ); }
// if magic quotes are active, then the slashes already exist
}
return $value;