David
David

Reputation: 4767

How to connect to a remote MSSQL database with PHP on Linux?

I've got a problem and there doesn't seem to be a strait forward solution.

I'm running a Linux server with PHP and need to connect to a MSSQL database on a remote server (I don't have control over this server). Speaking to my host, they say that it's not possible eto install the MSSQL extensions on a linux box as they are only available on Windows Servers. So, I'm looking to see what other options i have.

Any ideas how I can do this on a linux box?!

Upvotes: 1

Views: 6026

Answers (4)

conners
conners

Reputation: 1420

you have to do it via an ODBC connection.. odbc_connect() etc etc.. Microsoft has drivers for this http://www.microsoft.com/en-gb/download/details.aspx?id=28160.. (edit) I have done this without any of the issues posted... the php.net website for odbc_connect even gives mSSQL examples in the manual http://php.net/manual/en/function.odbc-connect.php

Upvotes: 1

dev-null-dweller
dev-null-dweller

Reputation: 29462

it's not possible eto install the MSSQL extensions on a linux box

They lied. It is possible, but it requires FreeTDS to compile.

Other solution is to use other host (with windows) to act as proxy to MSSQL server, and communicate with it by SOAP/REST

Upvotes: 3

rekire
rekire

Reputation: 47945

Commonly a database module is installed but in your case you could try to use a REST-API to talk with the MSSQL database. But that must be installed on a second server e.g. the database server itself.

Upvotes: 0

Related Questions