Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP, MSSQL, SQL SERVER, WAMP, PDO, Windows Authentication

I have searched the site and the web for a PROPER tutorial on how to connect from your WAMP PHP to a local SQL SERVER without success.

Articles I have found on this site are:

  • PHP to SQL Server without ODBC or MSSQL support
  • Connecting to SQL Server with PDO_MSSQL in PHP
  • Error connecting to SQL server with MSSQL and PHP
  • MSSQL error (saying not enabled when it is) using WAMP / PHP 5.3.4
  • Connecting to MSSQL server 2008 with PHP
  • PHP error connecting to MS SQL database using PDO_DBLIB

None of them really help me.

Can someone post a proper article on how to connect from WAMP PHP to a local SQL Server with Windows Authentication. Also if possible with SQL server authentication.

I have tried installing php_pdo_mssql, php_mssql, extensions but I am getting unable to connect to server errors. I can connect to the server through SQL Server management studio when I just type Database name: DEV-13 and put Windows Authentication as login credentials.

A tutorial to for installing PHP extensions and connecting to sql server for dummies would be perfect!

Please help.

like image 773
C0D3 Avatar asked Feb 14 '26 04:02

C0D3


2 Answers

Here is a guide from Microsoft. http://msdn.microsoft.com/en-us/library/cc296205%28v=sql.90%29.aspx

like image 141
jarchuleta Avatar answered Feb 15 '26 17:02

jarchuleta


Are you wanting to connect using the identity that Apache is running as, or a different user? If the same user as Apache, see http://msdn.microsoft.com/en-us/library/cc793139(v=sql.90).aspx . Am looking for another article now as to how to use arbitrary credentials.

Also, mssql_* is in my mind deprecated. It's a pain to find the right DLLs for it, and it's not very well supported (though one of the only options on Linux).

I suggest using sqlsrv through PDO. That way you get the benefits of the newest (Microsoft supported) connection method, and worst case if you have to change back to mssql_* drivers, you can just change the PDO connection string and be done (no query changes or anything).

like image 43
Corbin Avatar answered Feb 15 '26 17:02

Corbin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!