AforAlex
Posts: 85
Joined: Thu May 31, 2012 7:56 pm

Connecting to MS SQL Server from PHP

Tue Mar 14, 2017 11:34 pm

Hi,

I was wondering if anyone knew where I could go to for some help setting up a PHP site to access a MS SQL Server database.

I'm working on a project that's running a php site on the raspberry pi and I have been connecting back to a MySQL database which works lovely, except ultimately I need to push data back to a MS SQL Server database.

I'm able to transfer the data over from the MySQL to the SQL Server database but I was wondering about cutting out the middle man and connecting straight to the SQL Server database from my PHP website.

This is where I've got struck, any help on how I set up the access from RaspberryPi so that a PHP page can run SQL against the MS SQL Database. I guess I need to install some ODBC drivers?

Any help pointers would be very much appreciated as currently quite stuck as every search I do just seems to either tells me how to set up MySQL or how to set up Python to access MS SQL Server.

Thank you

Alex

User avatar
DougieLawson
Posts: 36306
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Connecting to MS SQL Server from PHP

Wed Mar 15, 2017 9:13 am

You'll need PHP:ODBC
http://php.net/manual/en/book.uodbc.php

Along with
http://www.unixodbc.org/

sudo apt-get install php5-odbc unixodbc unixodbc-bin
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

AforAlex
Posts: 85
Joined: Thu May 31, 2012 7:56 pm

Re: Connecting to MS SQL Server from PHP

Wed Mar 15, 2017 1:28 pm

Thank you, much appreciated

Return to “Advanced users”