duannai5879 2015-01-11 16:59
浏览 350
已采纳

使用bind_param()的PHP问题;

Good day, I'm not really familiar with PHP and i get this error when i try to execute my query.

Warning:

Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement in /Users/site/userpanel.php on line 10

Code:

$query="SELECT SUM(gebruiker_id) AS totalitems FROM inventory WHERE gebruiker_id = 1";
$stmt = $db->prepare($query);
$stmt->bind_param("s", $items);
$stmt->execute();
$result = $stmt->bind_result($col1);

Thanks in advance!

  • 写回答

2条回答 默认 最新

  • dongtuoao7987 2015-01-11 17:01
    关注

    You have to use a placeholder like this:

    $query="SELECT SUM(gebruiker_id) AS totalitems FROM inventory WHERE gebruiker_id = ?";
    $stmt = $db->prepare($query);
    $stmt->bind_param("s", $items);
    $stmt->execute();
    $result = $stmt->bind_result($col1);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?