i am using a prepared statement for a select on a period table:
$query_period = $mysqli->prepare("SELECT * FROM period WHERE date_start<= '?' AND date_end >='?'");
$query_period->bind_param('ss',$date_start,$date_end);
and the execution gives a parameter number error:
Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement
the error does not occur when i remove the " around the ? like this:
$query_period = $mysqli->prepare("SELECT * FROM period WHERE date_start<= ? AND date_end >=?");
but also the query does not match the correct result. how can i do this?
because if go like this:
$query_period = $mysqli->query("SELECT * FROM period WHERE date_start<= '$date_start' AND date_end >='$date_end'");
it all works fine
Bind parameters does work with dates.
There is absolutely no difference between a query with a placeholder and a query with the actual value. Neither for a date nor for any other data type.
Therefore, your problem is coming from whatever else direction. The input data, the data in database - you know. The sooner you realize that and stop barking the wrong tree, the sooner you will have your problem solved.