The following code fails on prepare:
$query = "UPDATE `table` SET `col` = ? WHERE `id` = ?";
if (!($stmt = $mysqli->prepare($query))) {
echo "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
}
//^^^ PREPARE fails
$stmt->bind_param("si", $val,$id);
if (!$stmt->execute()) {
echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
}
I get this: Warning: mysqli::prepare() [mysqli.prepare]: Couldn't fetch mysqli... What am I doing wrong in the code above? I checked the syntax documentation, but if I try to pas the query as an sql I do get a syntax error. Is there a good debugging tool for mysqli syntax errors?
You can do the following.
Hope this will work for you.