Getting the following error:
Fatal error: Cannot pass parameter 2 by reference in C:\xampp\htdocs\ppa\php\process_images.php on line 29
Simply trying to update a database record, the following debug code
$id = (int)$x;
echo $id.". Type: ".gettype($id);
produces this: 4. Type: integer So the variable is the correct type.
Here is my code
if (isset($_POST['delete'])) {
//Delete the image, first update the database, then move the image to a new folder.
foreach($_POST['product'] as $x) {
if ($stmt = $mysqli->prepare("UPDATE images SET dodelete = ? WHERE id = ?")) {
$id = (int)$x;
echo $id.". Type: ".gettype($id);
$stmt->bind_param("ii", 1, $id); <---- line 29
$stmt->execute();
$stmt->close();
} else {
echo "Unable to delete image!";
}
}
}
At first I was binding the $x variable directly from the foreach statement, which I thought was the issue as the error says it can't pass parameter by reference, but as you can see I made a new variable $id.