0

I have the following simple script:

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

When I remove the "WHERE" and also the $stmt->bind..., then the execute works fine and show me all rows of the table.

I can't print out the error with:

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

In the console of the browser I get only a 500 Error.

0 Answers0