PHP代码在$ pdo-> prepare时停止

时间:2014-10-13 17:07:47

标签: php database pdo insert

我试图使用PDO将一些数据插入到我的数据库中,但它只是在" 00I AM TRYING之后停止!"并且不输出任何错误。

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $error = FALSE;

    //in here it checks for a lot of different errors that 
    //the user may have input, if there is ANY error it 
    //will set the variable $error to TRUE and will stop the code.
    //This part does work perfectly and is not the problem

    echo (int)$error;
    if ($error == FALSE) try {
        echo (int)$error;
        echo 'I AM TRYING!';
        $query = $pdo->prepare('INSERT INTO users (inputA, inputB, inputC, inputD, inputE) VALUES (?,?,?,?,?)');
        echo (int)$error = FALSE;
        echo 'IT WORKS';
        $query->bindValue(1, $inputA);
        $query->bindValue(2, $inputB);
        $query->bindValue(3, $inputC);
        $query->bindValue(4, $inputD);
        $query->bindValue(5, $inputE);

        $query->execute();

        header('Location: index.php');
        exit;
    } catch(PDOException $e) {
        echo "Exception caught: $e";
}
}

我得到的输出是一个空白页面,其中包含以下信息:" 00I正在尝试!",这意味着代码在" 00I AM TRYING之后停止!"

关于什么是错的任何想法?

0 个答案:

没有答案