0

运行此代码时出现此错误。

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 语句,它可以工作。

4

2 回答 2

1

问题是这一行:

$arr=explode(",",`$upvoted);

你有一个不属于那里的额外反引号。它应该是:

$arr=explode(",",$upvoted);
于 2012-09-06T01:53:30.987 回答
0

由于 StackOverflow 的语法高亮突出显示(呵呵),您explode在前面的语句中有一个额外的反引号`$upvoted

$arr=explode(",",`$upvoted);
于 2012-09-06T01:54:05.247 回答