Francis Baptiste
Francis Baptiste

Reputation: 455

broken prepared statement for insert

I cannot for the life of me figure out why this prepared statement isn't working.

$thisInsert = $db->prepare("INSERT INTO conversations (person_a, person_b, exchange_count, inbox) values(?, ?, ?, ?)");
$thisInsert->bind_param('iiii', $activeUser, $passiveUser, 1, 1);
$thisInsert->execute();

Upvotes: 0

Views: 64

Answers (1)

Mark Baker
Mark Baker

Reputation: 212412

Values are bound by reference, not by value; so you can't bind a value like 1, only something like a variable containing the value that you want to bind

Quoting from the manual (my emphasis)

Note that mysqli_stmt_bind_param() requires parameters to be passed by reference

Upvotes: 2

Related Questions