0

I am trying to bind parameters dynamically using an array. This is the part of my code which is important and also shows debugging info:

$params = array_merge( array( $one ), array_values( $two ) );
echo '<pre>';
echo $query . '<br><br>';
print_r( $params );
call_user_func_array( array( &$stmt, 'bind_param' ), MakeValuesReferenced( $params ) );

This is the debugging info:

enter image description here

As you can see there are three question marks in my query, and three parameters added to bind_param. I thought this should be working. What am I doing wrong?

0

1 Answer 1

1

You can't quote the placeholder, that makes it the literal value and not a placeholder. Move the time into the binding and leave the placeholders on their own.

e.g.

where thedateandtime between ? and ?

then in the bind

($date . ' 00:00:00')

You also can't bind columns so the order by should be altered. Use a whitelist to compare the values before passing it into the query.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.