4

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?

zimdanen
  • 5,508
  • 7
  • 44
  • 89
  • You could install a service on your SQL server that provides data access to your web application by some other means. Perhaps soap or rest, or a custom web service. The best bet, though, is probably to find a different hostin company. – Jonathan Hall Jul 10 '11 at 22:48
  • I'd be talking your business elsewhere. Sounds like they don't even realy want to be running PHP, which under windows I can understand. – Scuzzy Jul 10 '11 at 23:18
  • Flimzy - I don't have access to the SQL Server itself. Flimzy/Scuzzy - Not a bad suggestion, but I found how to do it in PHP, so I'm going to stick with them. They're good once I'm situated - just a pain to do anything new (or deal with tech support, who are fairly useless). – zimdanen Jul 18 '11 at 20:36

1 Answers1

5

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(); 
} 
?> 
zimdanen
  • 5,508
  • 7
  • 44
  • 89