[英]Array syntax error PHP
I get the error *You have an error in your SQL syntax; 我收到错误*您的SQL语法有错误; check the manual that corresponds to your MySQL server version for the right syntax to use near '[0]' at line 1 * when trying to update and email. 检查与MySQL服务器版本相对应的手册以获取正确的语法,以在尝试更新和发送电子邮件时在第1 *行的'[0]'附近使用。
$updatelist = explode(",",$Limited);
print_r($updatelist); // echos Array ( [0] => samplemail@gmail.com [1] => samplemal@yahoo.com [2] => )
$totalupdates = count($updatelist)-1;
for ($y = 0; $y < $totalupdates; $y++)
{
$updatemail = "UPDATE tblusers SET date= '$date' WHERE Email = 'updatelist[$y]'";
$updatefree = mysql_query($updatemail);
echo $updatemail;
}
What's wrong with the $updatelist[$y] ? $ updatelist [$ y]有什么问题? Should it loop through $updatelist[0] to $updatelist[1] ? 是否应该通过$ updatelist [0]到$ updatelist [1]循环?
更改$updatelist[$y]
而不是updatelist[$y]
I think the problem is here: 我认为问题出在这里:
$updatemail = "UPDATE tblusers SET date= '$date' WHERE Email = 'updatelist[$y]'";
Try this: 尝试这个:
$updatemail = "UPDATE tblusers SET date = '$date' WHERE Email = '$updatelist[$y]'";
Try this code: 试试这个代码:
$updatelist = explode(",",$Limited);
print_r($updatelist); // echos Array ( [0] => samplemail@gmail.com [1] => samplemal@yahoo.com [2] => )
$totalupdates = count($updatelist)-1;
foreach ($updateList as $key=>$val)
{
$updatemail = "UPDATE tblusers SET date= '$date' WHERE Email = '".$val."'";
$updatefree = mysql_query($updatemail);
}
echo $updatemail;
尝试:
$updatemail = "UPDATE tblusers SET date= '".$date."' WHERE Email = '".$updatelist[$y]."'";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.