Hey! Long time no speak ^.^
I've been trying to make a query which would follow this logic (Which works in phpMyAdmin):
UPDATE member_food SET food_id=12 WHERE member_id=4 AND food_type="breakfast"
However, when I do it in PHP:
$sql_breakfast1 = "UPDATE member_food SET food_id ='$breakfast1' WHERE member_id='$id' AND food_type='breakfast'";
if ($mysqli->query($sql_breakfast1) === TRUE) {
echo "Query: " . $sql_breakfast1;
} else {
echo "Query: " . $sql_breakfast1 . "<br> Error: " . $mysqli->error;
}
When I navigate to this page after using my forms, I get this echo:
Query: UPDATE member_food SET food_id ='8' WHERE member_id='5' AND food_type='breakfast'
So, it is getting the information from my form... But in my database it sets the food_id to 1.
I've tried doing this:
$sql_breakfast1 = "UPDATE member_food SET food_id =? WHERE member_id=? AND food_type=?";
$stmt = $mysqli->prepare($sql_breakfast1);
if ( false===$stmt ) {
die($mysqli->error);
}
$rc = $stmt->bind_param('sis', $breakfast1, $id, 'breakfast');
if ( false===$rc ) {
die($stmt->error);
}
$rc = $stmt->execute();
if ( false===$rc ) {
die($stmt->error);
}
$stmt->close();
But I get the error: Fatal error: Cannot pass parameter 4 by reference on this line: $rc = $stmt->bind_param('sis', $breakfast1, $id, 'breakfast');
Thanks :)