调试:PHP MySQL变量数量与参数数量不匹配

时间:2016-10-21 13:57:10

标签: php mysql prepared-statement bindparam

我要做的是,使用占位符准备和绑定SELECT查询,但是有错误。

我的代码:

$stmt = $connection->prepare("SELECT `ID`, `booking`.`flightDestination`, `flightTime`, `typeOfFlight`, `flightDate` FROM `booking` JOIN `flight` ON `booking`.`ID` = `flight`.`flightNo` WHERE `booking`.`flightDestination` = '?' AND `flightDate` = '?' AND `typeOfFlight` = '?'");
if(!$stmt){
    echo "Prepare statement error";
    echo $connection->error;
}
$stmt->bind_param("sss",$flightDestination,$flightDate,$typeOfFlight); //binds the parameter $token as string
$stmt->execute();
$stmt->store_result();
$NOR = $stmt->num_rows;
$stmt->bind_result($getID,$getFlightDestination,$getFlightTime,$getTypeOfFlight,$getFlightDate);

我发现我的prepare语句包含3个占位符,而我的bind_param()中只包含3个变量。

然而输出是

  

变量数量与第76行C:\ xampp \ htdocs \ B-Flight \ flightSearch.php中预准备语句中的参数数量不匹配   目的地类型日期航班无出发时间

我想知道,bind_param()只将3个变量与3个占位符绑定,为什么甚至提到其他变量?

0 个答案:

没有答案