PHP and MS Access

后端 未结 5 1335
旧巷少年郎
旧巷少年郎 2020-12-04 01:30

How can we connect a PHP script to MS Access (.mdb) file?

I tried by including following PHP code:

$db_path =          


        
5条回答
  •  死守一世寂寞
    2020-12-04 02:01

    I'm not certain if this is a violation of best practices or security, but I would like to throw out this suggestion:

    set up an ODBC connection and include the database's password in the odbc advance settings. give the odbc conn a DSN name then save.

    in your code, just set up the connection like:

    try {
      $conn = @odbc_connect("DSNName", "", "", "SQL_CUR_USE_ODBC");
      // un and pw parameters are passed as empty strings since the DSN 
      // has knowledge of the password already.
      // 4th parameter is optional
    
      $exec = @odbc_exec($conn, $insert) or die ("exec error");
      echo "success!";
    }
    catch (Exception $e) {
      echo $e->getMessage();
    } // end try catch
    

提交回复
热议问题