Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

How to connect ODBC Database with PHP?

  • Difficulty Level : Expert
  • Last Updated : 03 Feb, 2021

The Microsoft Open Database Connectivity (ODBC) is a C application programming language interface. So the applications can access data from different database management systems.  The designers of ODBC aimed to make it independent of database systems and operating systems. In this article, we are using the Microsoft Access database to establish a connection.

Requirements: If ODBC Drivers are installed or the old version is installed, then update to the latest version or install the driver first 

  • Start XAMPP server by starting Apache
  • Write PHP script for Access database connection.
  • Run it in a local browser.
  • The database is successfully connected.

Steps to follow for ODBC connection to an MS Access Database:

  • Open the Administrative tools icon in your control panel

  • Double-click on the Data Sources (ODBC) icon inside.

  • Choose the System DSN tab.


  • Click on Add in the System DSN tab.

  • Select the Microsoft Access Driver, Click Finish

  • In the next screen, click on select to locate the database

  • Give the database a Data Source Name (DSN) as shown in the above image. Click ok.

Example: The following example demonstrates the simple connection script.


<!DOCTYPE html>
   //Storing DSN(Data Source Name created)
   //storing connection id in $conn
  $conn=odbc_connect($dsn,$user, $password);
  //Checking connection id or reference
  if (!$conn)
   echo (die(odbc_error()));
      echo "Connection Successful !";
  //Resource releasing

 Below output will be shown on the browser


Connection Successful !


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!