I am new to php and am having a problem in connecting a database to a page being used to book appointments. Can anybody advise me on this code and error?
$mysqli = new mysqli('host', 'user', 'pass', 'dbname');
$stmt = $mysqli->prepare("select * from bookings where MONTH(date) = ? AND YEAR(date) = ?");
$stmt->bind_param('ss', $month, $year);
$bookings = array();
if($stmt->execute()){
$result = $stmt->bind_result($month, $year);
if($result->num_rows>0){
while($row = $result->fetch()){
$bookings[] = $row['date'];
}
$stmt->close();
}
}
I am getting these errors:
Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement in /var/www/vhosts/222/1112657/webspace/httpdocs/menugeek.ie/booking-app/index.php on line 17
Notice: Trying to get property 'num_rows' of non-object in /var/www/vhosts/222/1112657/webspace/httpdocs/menugeek.ie/booking-app/index.php on line 18
Screenshots below of how my table 'bookings' in my database is set up. Thanks! Database screenshot 1 Database screenshot 2