<p>Currently we have a hybrid ASP/PHP setup connecting to a SQL Server 2005 database. But all the query work is done on the client side, I'd like to move some of this to PHP. </p>

<p>What driver and/or connection string is needed to connect to Sql Svr and what is the syntax to use in PHP?</p>

<hr>

<p>Update: OK so I was definitely trying to avoid using anything to do with copying DLLs etc. I'll look into the <a href="http://www.codeplex.com/SQL2K5PHP" rel="nofollow noreferrer">SQL2K5PHP</a> driver (thanks Vincent). @jcarrascal for the sake of clarity, by "client side" I mean our application is an internal web app that runs as an <a href="http://msdn.microsoft.com/en-us/library/ms536471.aspx" rel="nofollow noreferrer">HTA</a>, with all queries done via javascript calls to an ASP which actually submits the DB request.</p>

[{'answer_id': 19844, 'author': 'Espo', 'author_id': 2257, 'author_profile': 'https://Stackoverflow.com/users/2257', 'pm_score': 0, 'selected': False, 'text': '<p>PHP provides an extension for accessing Microsoft SQL Server databases. To use the SQL Server extension, all that is required is to activate the extension in the PHP configuration file.</p>\n\n<p>Details on <a href="http://msdn.microsoft.com/en-us/library/bb264561.aspx" rel="nofollow noreferrer">the MSDN page</a></p>\n'}, {'answer_id': 19851, 'author': 'Julio César', 'author_id': 2148, 'author_profile': 'https://Stackoverflow.com/users/2148', 'pm_score': 2, 'selected': False, 'text': '<p>Just use the mssql_connect() function like this:</p>\n\n<pre><code>$conn = mssql_connect(\'localhost\', \'sa\' , \'123456\')\n    or die(\'Can\\\'t connect.\');\nmssql_select_db(\'database\', $conn)\n    or die(\'Can\\\'t select the database\');\n</code></pre>\n\n<p>Functions relating to SQL Server are defined in the <a href="http://www.php.net/manual/en/book.mssql.php" rel="nofollow noreferrer">PHP manual for the MSSQL driver</a>.</p>\n\n<p>One question though, "all the query work is done on the client side" WTF? :D</p>\n'}, {'answer_id': 20427, 'author': 'Vincent', 'author_id': 1508, 'author_profile': 'https://Stackoverflow.com/users/1508', 'pm_score': 4, 'selected': True, 'text': '<p>You have two options:</p>\n\n<p>1) <strong>php_mssql extension</strong> : If you\'d like something that has the same API mysql and mysqli has, then use the php_mssql extension. But there is a catch, the bundled ntwdblib.dll file with PHP is not working. You have to find this file from a SQL Server 2000 installation or you can find it on the Internet. This API is supposedly not very reliable but I have been using it without problem for about one year.</p>\n\n<p><a href="http://ca.php.net/mssql" rel="noreferrer">http://ca.php.net/mssql</a></p>\n\n<p>2) <strong>Microsoft SQL Server 2005 PHP Driver</strong> : If you\'d like something more modern but which does not have the same API and is missing some important functions (mssql_num_rows). The big plus is that it is supported by Microsoft and is likely to work with a future version.</p>\n\n<p><a href="http://msdn.microsoft.com/en-us/data/cc299381.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/data/cc299381.aspx</a></p>\n'}]
['https://Stackoverflow.com/questions/19837', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1915/']