0

What I am trying to do is, to prepare and bind the SELECT query using placeholders, however there is an error.

My Codes:

$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);

I found that my prepare statement contains 3 placeholders, and in my bind_param() contains exactly 3 variables.

However the output is

Number of variables doesn't match number of parameters in prepared statement in C:\xampp\htdocs\B-Flight\flightSearch.php on line 76 Destination Type Date Flight No Departure Time Period

Am wondering, bind_param() only binds the 3 variables with the 3 placeholders, why did it even mention about the other variables?

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Byron Wong
  • 145
  • 9

0 Answers0