【发布时间】:2014-12-06 01:56:45
【问题描述】:
我第一次尝试使用准备好的语句,并在下面的代码中遇到了以下问题
错误:
警告:mysqli_stmt_bind_param() 期望参数 1 为 mysqli_stmt,布尔值
代码:
$stmt = mysqli_prepare($db, "INSERT INTO fragrances(name, description, essentialoils, topnotes, middlenotes, basenotes, reference, year, type, price, fragrancehouse, triangle, extractname, extractreference, extractprice, extractfragrancehouse, disccolour, collarcolour, actuatorcolour)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
mysqli_stmt_bind_param($stmt, 'sssssssssssssssssss', $name, $description, $essentialoils, $topnotes, $middlenotes, $basenotes, $reference, $year, $type, $price, $fragrancehouse, $triangle, $extractname, $extractreference, $extractprice, $extractfragrancehouse, $disccolour, $collarcolour, $actuatorcolour);
mysqli_stmt_execute($stmt);
我在这里查看了许多不同的问题,但他们的解决方案似乎都不适用于我的问题,有人知道问题是什么吗?
【问题讨论】:
-
准备失败。你需要得到
mysqli_error的输出。您的查询中也没有占位符。如果 mysqli 支持,请使用?或命名参数(我不确定)
标签: php mysql mysqli bindparam