Unable to pass parameter by reference in MySQLi

I am trying to pass a string to my prepared MySQLi statement, but it gives me an error:

Unable to pass parameter by reference in MySQLi

Here is the relevant code:

$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); 
+8
php mysql mysqli prepared-statement binding
source share
2 answers

'iiss' and '1' cannot be passed as a reference because they are not variables, but string constants. You need to create two variables with the specified values ​​and pass them, because the bind_param () function expects variables passed by reference.

Edit: this is '1', which causes the problem, not the name of the parameter associated ('iiss'). Sorry for the misinformation, I was in a hurry when I answered your question.

+20
source share

Check the $config_name argument. '1' does not pass as links

0
source share

All Articles