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のシンタックスハイライトが強調表示されているように(heh)、explodeステートメントの前に余分なバックティックがあります`$upvoted

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