PHP ODBC INSERT不起作用-没有错误


PHP ODBC INSERT does not work - no errors

为什么它不起作用?我没有错,但结果也没什么。

if($_SERVER["REQUEST_METHOD"] === "POST"){
$data_from_client = isset($_POST["data"]) && strlen($_POST["data"]) ? $_POST["data"] : null;
// Database path
$db = $_SERVER["SCRIPT_FILENAME"];
$db = str_replace("php/insert_query.php", "data/users/testuser.accdb", $db);
// Connect
$dbh = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)}; Dbq=$db; Uid=; Pwd=;");
// INSERT data
$count = $dbh->exec("INSERT INTO posts(username, date) VALUES ('Matthew', '2015')");
// echo the number of affected rows
echo $count;
// close the database connection
$dbh = null;

}

要确定错误的性质:

try {
    $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $count = $dbh->exec("INSERT INTO posts(username, date) VALUES ('Matthew', '2015')");
    echo $count;
} catch (PDOException $e) {
    echo $e->getCode() . '|' .$e->getMessage(); 
}