我花了整整一天的时间试图找出这个问题,没有运气。我已经看到了一些常数被直接用作争论的问题。尽管我的所有参数都是变量。我错过了真正明显的东西吗?PHP准备的语句错误:无法通过引用传递参数2
$one = 1;
$two = 2;
$three = 3;
if ( !($stmt = $mysqli->prepare('INSERT INTO test3 (one, two, three) VALUES (?, ?, ?)')) ) {
echo "Prepare failed (".$stmt->errno.") ".$stmt->error."\n";
$stmt->close();
exit();
}
if ( !($stmt->bind_param('iii',$one,$two,$three)) ) {
echo "Failed to bind (".$stmt->errno.") ".$stmt->error;
$stmt->close();
exit();
}
if ( !($stmt->execute) ) {
echo "Execute failed (". $stmt->errno.") ". $stmt->error."\n";
$stmt->close();
exit();
}
编辑:实际上,我是用bind_param但忘了改回来用不同的东西尝试之后。代码被复制并粘贴。将bind_value更改回bind_param后,我仍然得到相同的错误。编辑2:我觉得很蠢,我用一个新名字保存了我的php文件,所以我可以简化代码,但是我忘记更改POST方法的URL以反映这种变化。所以现在我得到的错误是:Undefined property: mysqli_stmt::$execute和MySQL日志相应的输出:
42 Connect [email protected] on testdb
42 Prepare [1] INSERT INTO test3 (one, two, three) VALUES (?, ?, ?)
42 Quit
+0
您一定这是有问题的代码?这是真实的代码吗? –
+1
你可以用行号发布完整的错误信息吗? –
+0
根据[PHP文档](http://php.net/manual/en/class.mysqli-stmt.php),没有'mysqli_stmt :: bind_value'这样的函数吗? –