Informatics Forum

ODBC Connection with PHP

Posted on: October 2, 2007

ODBC (Open Database Connectivity) is group of database driver which have been registered in the Windows. Sometimes when you install DBMS (ex : Microsoft Access, etc) installer include driver for ODBC. If you want to show what driver has been installed on you computer, you can Click Start->Run, please type : ODBCAD32 on textbox.

odbcad32.jpg

112.jpg

After that it will show a window, please open tab “Drivers”. So you can create connectivity based on list. ODBC can reduce requirement of function each database, because in PHP each database can have difference function.

CREATE Connection Class

Connection string maybe same with connection string on windows programming. Driver={SQL Server};Server=”.$ser.”;Database=”.$db,$user,$pass. Function odbc_connect for create connection with database. So we don’t scare if you will develop program with PHP and non mySQL.

class {

    function create_connection() {

        $ser=”LOCALMACHINE”; #the name of the SQL Server
$db=”mydatabase”; #the name of the database
$user=”myusername”; #a valid username
$pass=”my pass”; #a password for the username# one line
$conn=odbc_connect(“Driver={SQL Server};Server=”.$ser.”;Database=”.$db,$user,$pass);

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Pages

Blog Stats

  • 131,473 hits

Category

Online

visitor stats
October 2007
M T W T F S S
« Sep   Nov »
1234567
891011121314
15161718192021
22232425262728
293031  
%d bloggers like this: