Back to Top

PHP ODBC connection with MySQL

PHP ODBC connection with Mysql

MySQL database is usually used to store data for PHP application and data are stored using the MySQL configuration and connection.Today I am going to cover a topic which is to connect PHP and MySQL using ODBC connection as from last two-three days I was working on it.

To make ODBC connection with MySQL tables, First of all you need to install MySQL ODBC drivers that is Connector-ODBC and you can get ODBC drivers from Once MySQL ODBC connection driver installed in your PC, you need to configure it.

To Configure MySQL ODBC connection follow the below steps:

  1. Go to Contral Panel >> Administrative Tools and then click Data Sources (ODBC)
  2. To open the ODBC Data Source Administrator
  3. Choose the System DSN tab
  4. Click on Add in the System DSN tab
  5. Select MySQL ODBC 5.1 Driver, then click Finish
  6. Now need to configure the specific fields Data source Name for the DSN.
  7. Click OK to save the DSN

Let’s have a look


In above box, enter the name of the data source(database) you want to access and in the Server field, enter the name of the MySQL hostname that you want to access(e.g localhost) then in user and password field enter database username and password.

Also, Read MySQL Connection: Let be Assured and Database BackUp Script

Now you are connected with ODBC and you can write PHP code for odbc connection with MySQL.

The odbc_connect() function is used to connect to an ODBC data source and The odbc_exec() function is used to execute an SQL statement.

After connecting with ODBC, The odbc_fetch_row() function is used to return records from the result-set. This function returns true if it is able to return rows, otherwise false

Then, To retrieve fields The odbc_result() function is used to read fields from a record.

Let’s take one Example which show data after ODBC connection:


If you have any query or confusion in above article, Do let me know.Have you developed any application using ODBC, share your thoughts in below comments section.

Share on Facebook0

Share on LinkedIn0Tweet about this on TwitterShare on Google+0Buffer this pageDigg thisShare on Reddit0

Leave a Reply

Your email address will not be published. Required fields are marked *

Most Popular Posts

How to use Template Parameter in Joomla

Posted on 4 years ago


Function handling Functions in PHP

Posted on 5 years ago


The Reader’s Poll – June 2015

Posted on 1 year ago


The Reader’s Poll – August 2014

Posted on 2 years ago


The Reader’s Poll – June 2014

Posted on 2 years ago


The Readers’ Poll – May 2014

Posted on 2 years ago


The Readers’ Poll – August 2013

Posted on 3 years ago