我试图将一个字符串传递到我的 MySQLi 准备好的语句中,但它给了我错误:
I am trying to pass a string into my MySQLi prepared statement but it gives me the error:
在 MySQLi 中不能通过引用传递参数
Cannot pass parameter by reference in MySQLi
相关代码如下:
$kv = json_encode(array($key => $value));
$stmt->prepare("insert into rules (application_id, ruletype, rule_name, rule_info) values (?, ?, ?, ?);");
$stmt->bind_param('iiss', $application_id, 1, $config_name, $kv);
'1' 不能通过引用传递,因为它不是变量而是文字.您需要使用提到的值创建一个变量并绑定它,因为 bind_param()
函数需要通过引用传递的变量.
'1' cannot be passed by reference because it's not a variable but a literal. You need to create a variable with mentioned value and bind it instead because bind_param()
function expects variables passed by reference.
这篇关于无法在 MySQLi 中通过引用传递参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!