无法在MySQLi中通过引用传递参数 [英] Cannot pass parameter by reference in MySQLi
本文介绍了无法在MySQLi中通过引用传递参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将字符串传递到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中通过引用传递参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文