PHP ODBC connection with Mysql

by Bhumi // Dec 31,2011 // No comment

aa

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

  8. Click OK to save the DSN

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 retrive a fields The odbc_result() function is used to read fields from a record.

Lets take one Example which show data after ODBC connection:

OUTPUT

RELATED POST

Webservice in WordPress

Here i am going to explain new article about how to call webservice in wordpress. Webservices are useful to retrieve your contents ftom PHP to READ MORE

Clean HTML content in PHP

After a long long time i get time to write article and i am curious to write but didn’t get time. So, Today I am READ MORE

Convert RGB to Hex HTML code in PHP

Here, I am going to explain code which is used to get HTML Color Code from RGB( RGB stands for Red, Green, and Blue) Equivalent. READ MORE

To convert PHP array into Javascript array

Sometimes you want to get php array values into javascript as an array. Mostly when you are using ajax. In Ajax , we pass php READ MORE

The Readers’ Poll – June 2013

Chart is a graphical representation of dynamic data and php has very useful chart libraries using it easily create charts in php. So,Here is new READ MORE

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=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">