How can I strip out charactors like =\" - I want to get rid of the \ out of the code. I am using InnovaStudio WYSIWYG Editor and using that for formating html emails to send to subscribers. When I get the emails it looks like the following: <DIV>This is our last test of this message system, we hope that the url function is now working correctly.</DIV> <DIV> </DIV> <DIV><A href=\"http://www.photosales.co.nz\" target=_blank>http://www.photosales.co.nz</A></DIV> Code (markup): I have been trying to follow the following guide http://www.confuci.us/edit/documentation/default_start.htm with no success - I still can not get rid of those back slashes. Any ideas please.... I have the following for the textarea: <textarea name="msg" id="article" rows=4 cols=30> <? function encodeHTML($sHTML) { $sHTML=ereg_replace("&","&",$sHTML); $sHTML=ereg_replace("<","<",$sHTML); $sHTML=ereg_replace(">",">",$sHTML); return $sHTML; } if(isset($_POST["msg"])) { $sContent=stripslashes($_POST['msg']); //Remove slashes echo encodeHTML($sContent); } ?> </textarea> Code (markup): Which I thought would strip the slashes out.
He used that already, but he may need to use it twice. Also, you can use htmlspecialchars to do the conversion of tags from < to < etc...
Sorry, bit lost there. Below is the file that the form is being sent to for emailing: <?php $db_host = $_POST['host']; $db_user = $_POST['username']; $db_pass = $_POST['password']; $db_name = $_POST['db']; $body = $_POST['msg']; $sub = $_POST['subject']; $table = $_POST['table']; $row = $_POST['row']; $from = $_POST['from']; $return = $_POST['return']; // CONNNECT TO DATABASE $dbDB = mysql_connect($db_host, $db_user, $db_pass) or die("ERROR: Could not connect to backend database."); mysql_select_db($db_name) or die("ERROR: Could not select control database."); // Pull emails $results = mysql_query("SELECT $row FROM $table") or die("Could not pull emails<br>".mysql_error()); $sent = mysql_num_rows($results); if($row = mysql_fetch_assoc($results)) { do { $email_body = $body; $subject = $sub; $email_header = "From: $from\n"; $email_header .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal $email_header .= "Return-Path: <$return>\n"; $email_header .= "Content-type: text/html; charset=iso-8859-1\r\n"; mail($row["email"], $subject, $email_body, $email_header); } while ($row = mysql_fetch_assoc($results)); } else { echo "No Email Addresses to send."; } ?> Your message has been sent<br> <br><?php echo( $email_body ); ?> Code (markup):
I have found the following: $filtered_message = str_replace("\","",$_POST['msg']); But then I get the error: Parse error: syntax error, unexpected '"' in /home/photosal/public_html/manager/email-send.php on line 30 Need to get rid of the \ here is some of the code that comes through the email: <A href=\"http://www.photosales.co.nz\">http://www.photosales.co.nz</A> </DIV>
yeah sorry about that. you need to escape the \ so that it itself isn't escaping the " $filtered_message = str_replace("\\","",$_POST['msg']); PHP:
Still got <A href=\"http://www.photosales.co.nz\">http://www.photosales.co.nz</A> <?php $db_host = $_POST['host']; $db_user = $_POST['username']; $db_pass = $_POST['password']; $db_name = $_POST['db']; $body = $_POST['msg']; $sub = $_POST['subject']; $table = $_POST['table']; $row = $_POST['row']; $from = $_POST['from']; $return = $_POST['return']; // CONNNECT TO DATABASE $dbDB = mysql_connect($db_host, $db_user, $db_pass) or die("ERROR: Could not connect to backend database."); mysql_select_db($db_name) or die("ERROR: Could not select control database."); // Pull emails $results = mysql_query("SELECT $row FROM $table") or die("Could not pull emails<br>".mysql_error()); $sent = mysql_num_rows($results); if($row = mysql_fetch_assoc($results)) { do { $email_body = $body; $subject = $sub; [B]$filtered_message = str_replace("\\","",$_POST['msg']);[/B] $email_header = "From: $from\n"; $email_header .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal $email_header .= "Return-Path: <$return>\n"; $email_header .= "Content-type: text/html; charset=iso-8859-1\r\n"; mail($row["email"], $subject, $email_body, $email_header); } while ($row = mysql_fetch_assoc($results)); } else { echo "No Email Addresses to send."; } ?> Your message has been sent<br> <br><?php echo( $email_body ); ?> Code (markup):
The $email_body is from the contents of the wysiwyg editor - or the problem area that is doing the \ part. Should I be replacing the $filtered_message to $email_body?
yeah probably. try replacing email_body with filtered_message first. if that doesn't work to the str_replace on email_body instead. assuming that both are the same thing. hard to tell.
Pretty much nailed that one - thank you for your help. Now I just need to get outlook to be able to view the email as html. Thanks again