Errors like this are caused by missing or incorrect syntax, prior to where the error occurred. You should post all the code or at lease all the code up to the mail(...) statement.
If your code contains sensitive information (passwords...) xxxxxx them out.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
if (isset($_POST['send']) AND $_POST['send'] == "1"){
if (!preg_match('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+@([-0-9A-Z]+\.)+([0-9A-Z]){2,4}$/i', EscapeString($_POST['email']))) {
$error .="<div class=\"error\">$RegistrationError[2]</div>";
}
if (!isset($_POST['sendername']) AND $_POST['sendername'] == ""){
$error .= "<div class=\"error\">$RegistrationError[3]</div>";
}
if (!$error){
$_POST['senderemail'] = $_POST['sendername'];
$check = mysql_query("SELECT picid from $pic_tbl where picid = '".valid_id($_POST['pid'])."'") Or die (mysql_error());
$row = mysql_fetch_array($check);
} else {
echo "<tr><td><div style=\"padding:10px; text-align:center\" class=\"txt_dbrown_bold02\">$RecommendToFriend</div></td></tr></table></td>\n";
include("templates/referform.html.php");
include("templates/footer.html.php");
exit;
}
}
if (isset($_POST['op']) AND $_POST['op'] == "ds"){
if (!preg_match('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+@([-0-9A-Z]+\.)+([0-9A-Z]){2,4}$/i', EscapeString($_POST['email']))) {
$error .="<div class=\"error\">$RegistrationError[2]</div>";
} if (!preg_match('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+@([-0-9A-Z]+\.)+([0-9A-Z]){2,4}$/i', EscapeString($_POST['senderemail']))) {
$error .="<div class=\"error\">$RegistrationError[2]</div>";
}
if (!checkSecurityImage($_POST['security_refid'], $_POST['security_try'])){
$error .= "<div class=\"error\">$InvalidSecID</div>";
}
if (!isset($_POST['email']) AND $_POST['email'] == ""){
$error .="<div class=\"error\">$RegistrationError[2]</div>";
}
if (!isset($_POST['sendername']) AND $_POST['sendername'] == ""){
$error .= "<div class=\"error\">$RegistrationError[3]</div>";
}
if (!isset($_POST['senderemail']) AND $_POST['senderemail'] == ""){
$error .= "<div class=\"error\">$RegistrationError[2]</div>";
}
if (!$error){
$check = mysql_query("SELECT picid from $pic_tbl where picid = '".valid_id($_POST['pid'])."'") Or die (mysql_error());
$row = mysql_fetch_array($check);
I don't see anything either. However, unless some lines are missing form the start of the post, line 44 is further down in the file than you indicate -
PHP Code:
} else {
echo "<tr><td><div style=\"padding:10px; text-align:center\" class=\"txt_dbrown_bold02\">$RecommendToFriend</div></td></tr></table></td>\n";
include("templates/referform.html.php");
include("templates/footer.html.php");
exit;
} // <--------------- this is line 44 in the code you posted ---------------
}
Since this is after an include, it is possible that the problem is due to contents of the include file.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
The $from_address item has some problem. If there is a variable by that name, then the single-quote and closing bracket is where the problem is.
If you would have posted this using the PHP /PHP code wrappers instead of the QUOTE /QUOTE wrappers, the location of this problem would have stood out as the color change would not have changed back.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
I ran the code, commenting out the include/require, mysql function calls, and code with user function calls, and supplied some values for the if tests... and I don't receive the error. This would indicate that it must be coming from a line I commented out or from something in one of the include/require files.
Here is the modified code to just past the mail(...) function call -
PHP Code:
<?php
error_reporting(E_ALL); // error reporting I set
session_start();
// require("config.php");
// include_once("$full_path_to_public_program/session.php");
// include("templates/main.html.php");
// include("templates/leftside.html.php");
// include("templates/refer_header.html");
$_POST['send'] = "1"; // value I set
if (isset($_POST['send']) AND $_POST['send'] == "1"){
// if (!preg_match('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+@([-0-9A-Z]+\.)+([0-9A-Z]){2,4}$/i', EscapeString($_POST['email']))) {
// $error .="<div class=\"error\">$RegistrationError[2]</div>";
// }
$_POST['sendername'] = "sender"; // value I set
if (!isset($_POST['sendername']) AND $_POST['sendername'] == ""){
$error .= "<div class=\"error\">$RegistrationError[3]</div>";
}
if (!$error){
$_POST['senderemail'] = $_POST['sendername'];
// $check = mysql_query("SELECT picid from $pic_tbl where picid = '".valid_id($_POST['pid'])."'") Or die (mysql_error());
// $row = mysql_fetch_array($check);
$ReferEmail = str_replace("{SENDER}", $_POST['sendername'],$ReferEmail);
//$ReferEmail = str_replace("{PASSW}", $_POST['pass'],$ReferEmail); // this line was already commented out.
$ReferEmail = str_replace("{PHOTO}","<a href=\"$siteurl/?id={$row['picid']}\">{$siteurl}/?id={$row['picid']}</a>",$ReferEmail);
Edit: I also recommend echoing the contents of the variables, at least - $_POST['email'], $ReferEmailSubject, $message, and $headers to make sure they contain the expected contents.
Edit2: To send HTML email, in addition to the content type, your $header string needs a MIME version and a charset item.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Last edited by mab; 07-05-06 at 12:35 PM.
Reason: Additional troubleshooting