Hey,
Ok locally I am running PHP 4.2.3 to test my scripts.
The server I am uploading to is running 4.3.10.
Now I have an email script that needs to strip slashes added to the text box content. But as I add it into the database, I add slashes beforehand...
Anyway here is the code:
// insert record into database
$sql = "INSERT INTO tbl_mailing_sent SET
fld_id='',
fld_subject='$subject',
fld_text='$text',
fld_date = CURDATE(),
fld_time = CURTIME(),
fld_category='$category'";
$result2 = mysql_query($sql) or die
//("Error in query: $sql. " .mysql_error())
("There has been an error with your request, please try again later.")
;
//mail headers
$headers = "From: " .$mailingname. " <" .$mailingemail. ">\r\n";
$headers .= "Reply-To: " .$mailingname. " <" .$mailingemail. ">\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-MSMail-Priority: Normal\r\n";
$headers .= "X-Mailer: " .$mailingname. "\r\n";
// format text
$mail_text = func_links($text);
$text_formatted = nl2br($mail_text);
$text_formatted = stripslashes($text_formatted);
$mail_message = "<p>Hi ". $row['fld_name'] .",</p>
<p>". $text_formatted ."</p>
<p>". $html_signature ."</p>";
@mail($row['fld_email'], $subject, $mail_message, $headers);
This is the function code for func_links:
// convert links without <a> tags into links
function func_links($text)
{
// Match things beginning with [url]http://[/url] (or other protocols)
$NotAnchor = '(?<!"|href=|href\s=\s|href=\s|href\s=)';
$Protocol = '(http|ftp|https):\/\/';
$Domain = '[\w]+(.[\w]+)';
$Subdir = '([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?';
$Expr = '/' . $NotAnchor . $Protocol . $Domain . $Subdir . '/i';
$Result = preg_replace( $Expr, "<a href=\"$0\" title=\"$0\" target=\"_blank\">$0</a>", $text );
// Match things beginning with [url]www.[/url]
$NotAnchor = '(?<!"|href=|href\s=\s|href=\s|href\s=)';
$NotHTTP = '(?<!:\/\/)';
$Domain = 'www(.[\w]+)';
$Subdir = '([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?';
$Expr = '/' . $NotAnchor . $NotHTTP . $Domain . $Subdir . '/i';
return preg_replace( $Expr, "<a href=\"http://$0\" title=\"http://$0\" target=\"_blank\">$0</a>", $Result );
}
Now locally this works fine, I don't get any slashes in the way, but if I send online I get the slashes still - it makes no sense, the files are EXACTLY the same - I can only think it is due to the difference in PHP.
Is what I am doing not viable in PHP 4.3.10 but is ok in 4.2.3???
Any help would be great.
Cheers,
Chris