0

Can anybody figure out why my dynamically created prepared statement doesn't work. I keep getting the message

Warning: Wrong parameter count for mysqli_stmt::bind_param() in C:\xampp\htdocs\systemTests\dynamicsql2.php on line 53

I dynamically create the $sqlString and the $boundArray and the examples used below are what it returns. Can anybody figure out what I'm doing wrong?

<?php      
 $sqlString= "SELECT firstName, surname FROM usersDetails WHERE age = ? AND formClass = ?";
 $boundArray =  Array ( [0] => ss [1] => 22 [2] => testClass );

 $stmt = mysqli_prepare($conn, $sqlString);     
 $stmt->bind_param($boundArray);
 $stmt->execute();
 ?>
Dharman
  • 30,962
  • 25
  • 85
  • 135
bevan7
  • 63
  • 1
  • 2
  • 11
  • With *splat*. See: https://stackoverflow.com/questions/25045318/mysqli-prepared-statements-passing-an-array or take a closer look at man page for `bind_param`. – ficuscr Sep 29 '20 at 21:13
  • Awesome. Thanks. The ... fixed it. – bevan7 Sep 29 '20 at 21:32

0 Answers0