Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot pass parameter by reference in MySQLi [duplicate]

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

Cannot 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);
like image 596
chustar Avatar asked Apr 06 '11 16:04

chustar


1 Answers

'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.

like image 68
N.B. Avatar answered Sep 19 '22 09:09

N.B.