1

基本上这是我的 php pdo 插入代码

$dbName = $_SERVER["DOCUMENT_ROOT"] . "/web/admin/mindb1.mdb";
//$dbName = "mindb1.mdb";
if (!file_exists($dbName)) {
    die("Could not find database file.");
}
$db = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$dbName; Uid=; Pwd=;");

$sql  = "INSERT INTO Anggota (`Tarikh Anggota`, `No Kp`, `No Kp Lain`) VALUES ('13/03/1970', 'b111111', 'b111111')";
$db->query($sql);

但似乎没有插入任何内容。而不是我们返回的任何错误消息。但是像下面这样运行选择查询就可以了

$sql  = "SELECT ID, `Tarikh`, `NoKp`, `Nama`  FROM Anggota order by ID";

$result = $db->query($sql);
while ($row = $result->fetch()) {
    $id        = $row["ID"];
    $tarikhAnggota = $row["Tarikh"];
    $noKp       = $row["NoKp"];
    echo "id: ".$id." tarikhAnggota: ".$tarikhAnggota." noKp: ".$noKp."<Br>";
}
4

0 回答 0