如何修复“致命错误:未捕获错误:在bool上调用成员函数bind_param()”第5行

时间:2020-07-10 20:48:45

标签: php mysqli boolean

我正在制作日历系统,并不断出现此错误,但不知道如何解决。

致命错误:未捕获错误:在A:\ xampp \ htdocs \ practice \ index.php:5堆栈中的bool上调用成员函数bind_param():5堆栈跟踪:#0 A:\ xampp \ htdocs \ practice \ index。 php(267):build_calendar(7,2020)#1 {main}在第5行的A:\ xampp \ htdocs \ practice \ index.php中抛出

<?php

function build_calendar($month, $year) {
    $mysqli = new mysqli('localhost', 'root', '', 'bookingcalendar');
    $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->get_result();
        if ($result->num_rows > 0) {
            while ($row = $result->fetch_assoc()) {
                $bookings[] = $row['date'];
            }

            $stmt->close();
        }
    }
}

0 个答案:

没有答案
相关问题