by Bhumi //Dec 31,2011 // No comment
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.
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.
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.
$conn=odbc_connect('data source name','username','password');
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.
$firstname = odbc_result($resultset,"FirstName");
Lets take one Example which show data after ODBC connection:
// First parameter is your DSN name, second is database username and third is database password
$sql="SELECT * FROM users";
echo "<th>First Name</th>";
echo "<th>Last Name</th></tr>";
$firstname = odbc_result($rs,"FirstName"); // second parameter contain a column name
$lastname = odbc_result($rs,"LastName");
First Name Last Name
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
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
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
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
Posted on Mar 2,2012
Posted on Dec 1,2011
Posted on Nov 26,2011
Posted on Jan 18,2013
Posted on Dec 12,2011
Be a Contributor at CreativeDev.Write an article or tutorial to the community and share some of your knowledge!