I recently had to connect to an MSSQL Server using PHP on an Ubuntu system using PHP. To connect to MSSQL using PHP 5.6 we’ll need to use PDO’s DBLIB (PDO_DBLIB). So let’s install the required packages using following commands:
Installing FreeTDS & Dependencies
All set!, now you should be able to get access to the SQL server database with PHP. Let’s test it with below code
If you get error like below shown
SQLSTATE Adaptive Server connection failed (severity 9)
change the connection string parameters like shown below –
I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.
I am Arjun from Hyderabad (India). I have been working as a software engineer from the last 7+ years, and it is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.