I am trying to make a simple search process with (noob) codes like this:
$prep->prepare("SELECT * FROM details WHERE id REGEXP '?'");
$prep->bind_param("s", $search_query);
It gives me this warning:
Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement
I am guessing it could be because the question mark is also used for RegExp (optional previous character).
Any idea about how to use REGEXP inside prepared statements (without conflicting question marks)?
Thanks.
Take out the single quotes around the ?. Your code should read:
$prep->prepare("SELECT * FROM details WHERE id REGEXP ?");
$prep->bind_param("s", $search_query);
As it stands now, you are passing in one param, but the ? in single quotes is treated as a string, not a parameter marker.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With