Parsing Mysqli Prepare语句上的分析错误
我在运行此代码时遇到此错误Parsing Mysqli Prepare语句上的分析错误,parsing,mysqli,php,Parsing,Mysqli,Php,我在运行此代码时遇到此错误 Parse error: syntax error, unexpected 'users_kudos_to_posts' (T_STRING) 密码 if ($number > 0) { $arr=explode(",",`$upvoted); //If I comment out everything below I still get the error. But if I comment out //the above code, then the e
Parse error: syntax error, unexpected 'users_kudos_to_posts' (T_STRING)
密码
if ($number > 0) {
$arr=explode(",",`$upvoted);
//If I comment out everything below I still get the error. But if I comment out
//the above code, then the error goes away.
if (in_array($primary_id, $arr)) {
array_push($arr, $primary_id);
$new_string = implode(",", $arr);
//the line below is where the parse error is pointing too.
if ($stmt2 = $mysqli->prepare("UPDATE `users_kudos_to_posts` SET `upvoted` = ?
WHERE `user_id` = ?")) {
$stmt2->bind_param('si', $new_string, $session_user_id);
$stmt2->execute();
$stmt2->close();
}
}
}
令人疯狂的是,我在同一页代码中有其他多个准备好的语句,它们使用相同的sql语句,除了列中的更改之外,它们都可以工作,但这并不起作用
另外,我在phpmyAdmin中运行了sql语句,它可以正常工作 问题是这一行:
$arr=explode(",",`$upvoted);
你有一个额外的背勾,不属于那里。应该是:
$arr=explode(",",$upvoted);
正如StackOverflow的语法高亮显示(heh)一样,在
`$upvoted
前面的explode
语句中有一个额外的反勾号:
$arr=explode(",",`$upvoted);
听起来像是PHP语法错误。也许你做了更进一步的事。如果你把那句话注释掉呢?错误消失/改变了吗?我注释掉了问题中显示的代码,错误仍然出现。我以前从未见过这种情况。这意味着错误更严重了。你很可能在某个地方多了一个或少了一个引号。我建议您使用一个具有语法突出显示的文本编辑器,因为这可能会使错误更加明显。请检查问题代码中的注释。我用注释部分的结果更新了它。找到了。对这些章节进行注释有帮助。如果你回答我,我会相信你的。