Armand Armand - 3 months ago 6
MySQL Question

Update Statement Error with MySQLi

I am getting the following error trying to update a record using MySQLi

"Warning: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, boolean given in"

Please see my code here:

$query_task_update = "update tasks set (display_order) = (?) where task_id '".$last_task_id."'";

$stmt_task_update = mysqli_prepare($dbc, $query_task_update);

mysqli_stmt_bind_param($stmt_task_update, "i", $display_order);

mysqli_stmt_execute($stmt_task_update);

Answer
$query_task_update = "update tasks set display_order=? where task_id=?";

$stmt_task_update = mysqli_prepare($dbc, $query_task_update);

mysqli_stmt_bind_param($stmt_task_update, "ii", $display_order, $last_task_id);

mysqli_stmt_execute($stmt_task_update);
Comments