PHP ODBC connection with Mysql

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

aa
Share This:Share on FacebookShare on LinkedInTweet about this on TwitterShare on Google+Share on RedditBuffer this pageDigg thisEmail this to someoneFlattr the authorShare on StumbleUponShare on TumblrPin on Pinterest

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

Method Chaining in PHP

Share This: Method Chaining is the new feature of object-oriented approach introduced in PHP5.Today I am going to explain how to use method chaining in READ MORE

To create zoho leads using PHP

Share This: Today i am going to explain about how to create zoho leads from php. Zoho provide online lead management system.Zoho leads take details READ MORE

Webservice in WordPress

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

Clean HTML content in PHP

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

Convert RGB to Hex HTML code in PHP

Share This: Here, I am going to explain code which is used to get HTML Color Code from RGB( RGB stands for Red, Green, and READ MORE

Leave a Reply

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


9 × = seventy two

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="">