ODBC Connection with PHP
October 2, 2007 — foruminformatikaODBC (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.
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);
}
}

