0

I have this code, I am running from a cronjob. Although, I get this error:

SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens

This is my code:

$TIME_TO_CLICK = (int) date('i');
$HOUR_TO_CLICK = date("H");

if($TIME_TO_CLICK <= 20){
    $QUERY_WHERE = "`click_hour` = '$HOUR_TO_CLICK' AND `click_minute` BETWEEN 1 AND 20";
} else if($TIME_TO_CLICK > 20 && $TIME_TO_CLICK <= 40){
    $QUERY_WHERE = "`click_hour` = '$HOUR_TO_CLICK' AND `click_minute` BETWEEN 20 AND 40";
} else if($TIME_TO_CLICK > 40 && $TIME_TO_CLICK < 60){
    $QUERY_WHERE = "`click_hour` = '$HOUR_TO_CLICK' AND `click_minute` BETWEEN 40 AND 60";
} else {        
    $QUERY_WHERE = "`click_hour` = '$HOUR_TO_CLICK'";
}

$QUERY_XEON = $dbh->prepare("SELECT * FROM `xeon_users_rented` WHERE $QUERY_WHERE;");

1 Answer 1

2

You only did a Prepare Should still need to execute the query with some data

SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number     of tokens

This means that you didn't provide enough info in the query. Try changing

$dbh->prepare 

to

$dbh->query

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.