PDO似乎不会执行

时间:2016-10-24 15:09:48

标签: php mysql pdo

我有以下简单的脚本:

$pdo = new PDO('mysql:host=xxx;dbname=xxx', 'xxx', 'xxx');

    $inputdate = strtotime($_POST['datum']);

    $start_date = date('Y-m-d H:i:s', mktime(0, 0, 0, date("m", $inputdate), date("d", $inputdate), date("Y", $inputdate)));
    $end_date = date('Y-m-d H:i:s', mktime(23, 59, 59, date("m", $inputdate), date("d", $inputdate), date("Y", $inputdate)));

    $sql = "SELECT logdate, ipadnummer, dateiname, dateigroesse, successfull 
            FROM appupload 
            WHERE logdate >= :start_date AND logdate <= :end_date 
            ORDER BY logdate DESC";

    $stmt = $pdo->prepare($sql);

    $stmt->bind(":start_date", $start_date, PDO::PARAM_STR);
    $stmt->bind(":end_date", $end_date, PDO::PARAM_STR);


    $stmt->execute();

当我删除“WHERE”以及$ stmt-&gt; bind ...时,执行正常并显示表格的所有行。

我无法打印出错误:

$stmt = $pdo->prepare('bogus sql');
if (!$stmt) {
    echo "\nPDO::errorInfo():\n";
    print_r($pdo->errorInfo()); 
}

在浏览器的控制台中,我只得到500错误。

0 个答案:

没有答案