[nycphp-talk] PHP and SQL Server 7

Joseph Crawford codebowl at
Thu Jan 20 11:14:54 EST 2005

Hey everyone,

i am still struggling to get PHP to connect to a remote database.  I
am now using a windows host since connecting from linux was a true
pita.  However i still cannot get it to work properly.

this is the code i have that doesnt work at all, always says failed to respond

if($conn = mssql_connect($hostname,$username,$password)) {
 mssql_select_db($dbName) or die('cannot select db');
 $sql = "select id, bath_level from idxmls1 where mod_date_time
>'2005-1-1 00:00:00'";
 $res = mssql_query($sql, $conn) or die('query error');
 $data = mssql_fetch_array($res) or die('fetch error');
 echo '<pre>';
 echo '</pre>';

here is some example code that i found, it connects and starts
retrieving data however i am not sure how to use this type of COM and
could use some direction as to what to search for. I did a search for
ADO and i hadnt a clue what i was looking for lol.

$db = new COM("ADODB.Connection");
$dsn = "DRIVER={SQL Server};
SERVER=;UID=******;PWD=******; DATABASE=******";
$rs = $db->Execute("select * from idxmls1 where mod_date_time
>'2005-1-1 00:00:00'");

while (!$rs->EOF)
   echo $rs->Fields['column']->Value."<BR>";

when i use this i get a ton of errors like the following

Warning: main(): Invoke() failed: Exception occurred. Source:
ADODB.Fields Description: Item cannot be found in the collection
corresponding to the requested name or ordinal. in
C:\Domains\\wwwroot\test.php on line 16

then it times out after 60 seconds of running.

any help would be appreciated

Joseph Crawford Jr.
Codebowl Solutions
codebowl at

More information about the talk mailing list