The information in this article applies to:
Details For more information on ODBC with PHP, please review the following:
Below is a simple PHP script to demonstrate how to connect to a MS SQL database using a DSNLess connection.
PHP Builder tutorial - http://www.phpbuilder.com/columns/jayesh20021029.php3
PHP Documentation on ODBC connections - http://www.php.net/manual/en/ref.odbc.php
Sample code:
1
2 <html> 3 <head><title>PHP SQL TESTtitle>head> 4 <body> 5 <h2>MS SQL / DSN Testh2> 6 <table border="1"> 7 php 8 $ConnString="DRIVER={SQL Server};SERVER=;DATABASE="; 9 $DB_User="sqlusername"; 10 $DB_Passwd="sqlpassword"; 11 $QueryString="SELECT id, FirstName, LastName, Email FROM tblContact"; 12 $Connect = odbc_connect( $ConnString, $DB_User, $DB_Passwd ); 13 $Result = odbc_exec( $Connect, $QueryString ); 14 echo "\t" . " |
|||
id | FirstName | LastName> | |
" . $id . " | " . $FirstName . " | " . $LastName . " | " . $Email . " | \n";