PHP Code:
You need to be aware that the PHP fetch path is Realpath
Copy Code code as follows:
<?php
$connstr = "Driver={microsoft Access DRIVER (*.mdb)}; Dbq= ". Realpath ("Data.mdb");
$connid =odbc_connect ($connstr, "", "", SQL_CUR_USE_ODBC);
$issuetime =date ("y-m-d h:i:s");
$sql = "INSERT INTO test values (" "," ",...)";
$result =odbc_exec ($connid, $sql);
if ($result) echo "successful";
else echo "failed";
?>
The second:
Copy Code code as follows:
? Php
Create an ADO connection
$conn = @new COM ("ADODB. Connection ") or Die (" ADO Connection Failed! ");
$connstr = "Driver={microsoft Access DRIVER (*.mdb)}; Dbq= ". Realpath ("Temp/tempdata.mdb");
$conn->open ($CONNSTR);
To create a recordset query
$rs = @new COM ("ADODB. RecordSet ");
$rs->open ("SELECT * from Blog_content", $conn, 1, 3);
echo $rs->fields["Log_title"]->value; Output Log_title Field
echo "<br/>";
$rs->movenext (); Move the recordset pointer down
echo $rs->fields["Log_title"]->value;
$rs->close ();
?>
Method three: With ODBC, in the ODBC Governance for Db1.mdb to build a system data source (generally require server permissions, not recommended)
Name: Dbdsn (You can set it yourself)
Driver: Microsoft Access Driver (*. MDB)
Code:
Copy Code code as follows:
$Conn = Odbc_connect ("Dbdsn", "admin", "123"); Connecting to a data source
$Doquery =odbc_exec ($Conn, "select * from table name where Condition");//Execute Query