0

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();
Dharman
  • 30,962
  • 25
  • 85
  • 135
Amy
  • 186
  • 8
  • Aside from the SQL syntax issues you are using the PHP functions incorrectly. Have you look at a tutorial on this topic? – user3783243 May 11 '22 at 05:08

1 Answers1

3

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();
hammer
  • 82
  • 10