PHP ODBC connection with Mysql

PHP ODBC connection with Mysql

Share: Share on Facebook0Share on LinkedIn2Tweet about this on Twitter1Share on Google+3Share on Reddit0Buffer this pageDigg thisEmail this to someoneShare on StumbleUpon0Share on TumblrPin on Pinterest0Print this page

Today I am going to cover a topic say ODBC connection with PHP and MySQL and Since 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 http://www.mysql.com/downloads/connector/odbc/. 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

Mysql ODBC DSN

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 host-name that you want to access(e.g localhost) then in user and password field enter database username and password.

Also Read:
Solution:Internet connection issue on AndroidEmulator
MySQL Connection: Let be Assured
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 a fields The odbc_result() function is used to read fields from a record.

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

 

First Name

 

OUTPUT

 

Share: Share on Facebook0Share on LinkedIn2Tweet about this on Twitter1Share on Google+3Share on Reddit0Buffer this pageDigg thisEmail this to someoneShare on StumbleUpon0Share on TumblrPin on Pinterest0Print this page

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Most Popular Posts

GoTo statement in PHP

Posted on 3 years ago

Bhumi

Table layout using DIV tags

Posted on 2 years ago

Bhumi

Mysql String Function FIND_IN_SET( )

Posted on 3 years ago

Bhumi

Post via e-mail in WordPress

Posted on 3 years ago

Bhumi

New Features in MySQL 5.6

Posted on 3 years ago

Bhumi

DEVELOPER POLL

The Reader’s Poll – June 2015

Posted on 1 month ago

Bhumi

The Reader’s Poll – August 2014

Posted on 11 months ago

Bhumi

The Reader’s Poll – June 2014

Posted on 1 year ago

Bhumi

The Readers’ Poll – May 2014

Posted on 1 year ago

Bhumi

The Readers’ Poll – August 2013

Posted on 1 year ago

Bhumi