i have table name "pages" with "id,title,slug" columns,I am working on core php and trying to use "parameterized update query",whenever i execute my query then its giving me following error
Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables
Here is my code,Where i am wrong ?
$sql = "UPDATE pages SET title=? WHERE slug=? AND id=?";
$stmt= $conn->prepare($sql);
$stmt->bind_param($title,$slug,$headingid);
$stmt->execute();
CodePudding user response:
While binding a param you should defined what type of is it, like in your case as I guess, title is string
, slug is string
and id is integer
$sql = "UPDATE pages SET title=? WHERE slug=? AND id=?";
$stmt= $conn->prepare($sql);
$stmt->bind_param("ssi", $title,$slug,$headingid);
$stmt->execute();