MySQLi查询无声地失败但在SQL shell上成功

时间:2014-09-25 22:13:30

标签: php mysql sql mysqli

我试图从我的OsTicket安装中提取一些数据,但出于某种原因,第一个SQL查询无声地失败(行开始:$openTickets)。但是,当输入MySQL shell时,查询会起作用。

<?php
    define('INCLUDE_DIR','dumb hack');
    require_once("./include/ost-config.php");

    $mysqli = new mysqli(DBHOST, DBUSER, DBPASS, DBNAME);
if ($mysqli->connect_error) {
    die("Couldn't Connect to MySQL Database.\nError (" . $mysqli->connect_errno . "): " . $mysqli->connect_error);
}

$openTickets = $mysqli->query("SELECT ticket_id, number, user_id FROM ost_ticket WHERE status='open'");

[...snip...]
?>

1 个答案:

答案 0 :(得分:0)

请参阅MySQLI errno

$openTickets = $mysqli->query("SELECT ticket_id, number, user_id FROM ost_ticket WHERE status='open'");
if ($openTickets === false) {
    printf("Errorcode: %d\n", $mysqli->errno);
}