下面的电子邮件查询应该由名为“ttemail”的字段为0触发。当我尝试使用它时,我收到You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1
。
看来该电子邮件正在发送至少第一个用户名,其中ttemail = 0。
任何想法为什么?
提前致谢,
约翰
if($row["ttemail"] == 0){
$mailaddress = $row['email'];
$link1 = "<a href='http://www...com/page.php'>Page Title</a>";
$message1 = "Congratulations, message.
<br>
<br>
More Message
<br>
<br>
Please click the link below to see more.
<br>
<br>
$link1
";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: Website Name <no-reply@website.com>" . "\r\n";
$queryem = mail($mailaddress, "Congratulations, message
$submission.", $message1, $headers);
//$ttquery = sprintf("Update login SET ".$row['ttemail']." = '1' WHERE username = ".$row['username']."");
mysql_query($queryem) or die(mysql_error());
mysql_query($ttquery) or die(mysql_error());
} else {
}
答案 0 :(得分:0)
我认为你错过了'where where子句。检查下面更正的查询 -
$ttquery = sprintf("Update login SET ".$row['ttemail']." = '1' WHERE username = '".$row['username']."'");