我有这个代码,我是从cronjob运行的。虽然,我得到这个错误:
SQLSTATE [HY093]:参数号无效:绑定变量数与令牌数不匹配
这是我的代码:
$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;");
答案 0 :(得分:2)
你只做了准备还是需要用一些数据来执行查询
SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
这意味着您未在查询中提供足够的信息。 尝试更改
$dbh->prepare
到
$dbh->query