zimdanen
zimdanen

Reputation: 5626

PHP to SQL Server without ODBC or MSSQL support

I'm in a situation where my Windows hosting has PHP support, but the PHP is not configured to support ODBC or MSSQL. I can't get them to change that, so I'm wondering if there's a way to connect to SQL Server through other means - maybe including some files that provide the functions that I'd need?

Upvotes: 4

Views: 4874

Answers (1)

zimdanen
zimdanen

Reputation: 5626

Leaving it up here in the hopes that it will make it easier for other people to get around this type of limitation.

Copied here for completeness:

<?php 
$db = new COM("ADODB.Connection"); 
$dsn = "DRIVER={SQL Server}; SERVER={SERVER};UID={USER};PWD={PASS}; DATABASE={DB}";
 $db->Open($dsn); 
$rs = $db->Execute("SELECT * FROM table"); 

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

Upvotes: 5

Related Questions