Forum Moderators: coopster

Message Too Old, No Replies

Strings escaped in the mail inbox

         

dbarasuk

3:08 am on Dec 27, 2007 (gmt 0)

10+ Year Member



Hi,

Below is the code used to send an email.

However when I open the message sent by PHP, I realize that the single quotes are being escaped and I don't know how to change that from the source code.

For example if I write you'll enjoy, the output is you\'ll enjoy

this is the code:

<?php
include('../includes/connection.inc.php');
if(array_key_exists('sendmail', $_POST)) {

// define connection object
$darconn = dbconnect('Admin');
// define the sql query
$sql = "SELECT email FROM friends";
// execute query
$result = mysql_query($sql) or die("Unsuccessful database connection");
// retrieve row

while($row = mysql_fetch_array($result, MYSQL_BOTH)) {
$to = $row['email'];
$subject = $_POST['subject'];
$Message = strip_tags(trim($_POST['sentmail']));
$headers = "FROM: desk@example.com";
$message=Array();
// prevent sending a message when fields are empty
if(empty($to) or empty($Message)or empty($headers) or empty($subject)){
$message = "Please, be aware that one or more fields were not filled in.";
}
else {

// send the email
$sendmail=mail($to, $subject, $Message, $headers);

if($sendmail) {
$message = "The newsletter was successfully sent to $to";
}
else {
$message ="There was an error sending the newsletter to $to, try again!";
}

}




}


}




?>

Also, as the $to is enclosed in the while loop, I expected to get a list of all the mails to which the message was sent to, but i get a confirmation message only for the last mail on the list. How can I understand that and also change it from my source code so that I get a list of all the mails to which the message was sent to and not only the sole mail of the list.

Any help?

regards,
dbarasuk

[edited by: eelixduppy at 4:39 am (utc) on Dec. 27, 2007]
[edit reason] removed email specifics [/edit]

Habtom

4:38 am on Dec 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It seems you have your 'magic quotes' (magic_quotes_gpc) enabled.

You can however easily remove slashes using the function:

stripslashes($variable);