简体   繁体   中英

Php Prepared Statement Returning 0 in Binded Variables, SQL Statement works fine in DB

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

If I run the query in the db, its working fine, but somehow the values dont bind to the vars... its returning "0" instead of "1" any ideas?

Right after this stmt im running

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

which works completely fine.

哈哈,天哪,不敢相信这个问题有多么愚蠢,只是忘了拿来...抱歉哈哈,但有时在成千上万的代码行中迷失了,您没有注意到最明显的问题...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM