// Load Filters
        $stmt = $mysqli->prepare("
        SELECT
        display_showCancelled,
        display_showCompleted,
        display_showNotPossible
        FROM `ticketing_settings`
        WHERE user = ?
        ");
        $stmt->bind_param('i', $_SESSION['userID']);
        $stmt->execute();
        $stmt->store_result();
        $stmt->bind_result($displayCancelled, $displayCompleted, $displayNotPossible);

如果我在数据库中运行查询,它可以正常工作,但不知何故这些值没有绑定到变量。。。它返回“0”而不是“1”有什么想法吗?
就在这个stmt im运行之后
            $stmt = $mysqli->prepare("SELECT
        ticketing_tickets.id,
        ticketing_tickets.description,
        ticketing_type.responsible,
        ticketing_tickets.date_created,
        users.firstname,
        users.lastname,
        ticketing_type.name,
        ticketing_tickets.status,
        ticketing_status.name
        FROM `ticketing_tickets`
        LEFT JOIN ticketing_status ON ticketing_tickets.status = ticketing_status.id
        LEFT JOIN ticketing_type ON ticketing_tickets.type = ticketing_type.id
        LEFT JOIN users ON ticketing_tickets.creator = users.id
        WHERE ticketing_tickets.status NOT LIKE ?
        AND ticketing_tickets.status NOT LIKE ?
        AND ticketing_tickets.status NOT LIKE ?
        AND ticketing_tickets.status NOT LIKE ?
        ");
        $ticketStatusReq = 1;
        $stmt->bind_param('iiii', $ticketStatusReq, $displayCancelled, $displayCompleted, $displayNotPossible);
        $stmt->execute();
        $stmt->store_result();
        $stmt->bind_result($ticketId, $ticketDescription, $ticketResponsible, $ticketDate, $ticketFirstname, $ticketLastname, $ticketTypeName, $ticketStatus, $ticketStatusName);

完全可以。

最佳答案

哈哈,天啊,真不敢相信这件事有多蠢,竟然忘了拿。。。很抱歉,哈哈,但有时在数千行代码中丢失,你不会注意到最明显的问题。。。

关于php - PHP预准备语句在绑定(bind)变量中返回0,SQL语句在DB中工作正常,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32786955/

10-11 22:04