Cannot connect to MSSQL within PHP


I'm trying to connect to an MSSQL database from with PHP using the following;

$db_conn = mssql_connect('', "sa", "myPassword") or die( "<strong>ERROR: </strong>");

Open in new window

However, all I keep getting is the following message;

Fatal error: Call to undefined function sqlsrv_connect()

The connection details are correct as I can login using RazorSQL, can anyone suggest why this isn't working?

I've also edited freetds.conf and added the following;

        host =
        port = 50109
        tds-version = 7.0

Open in new window

and then used this in the connection;

$db_conn = mssql_connect('LOCUMS', "sa", "myPassword") or die( "<strong>ERROR: </strong>");

Open in new window

This returns exactly the same error.

I do seem to be able to connect to the server from the command line;

tsql -S LOCUMS -U sa
locale is "en_GB.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SheppardDigitalAuthor Commented:
ok, figured this out.

I enabled the freetds logs, and noticed permission denied in the log file. A quick google and the first link suggested disabling SELINUX, did that and the connection was successful.

This is an internal development server, so I don't mind disabling SELINUX.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SheppardDigitalAuthor Commented:
Resolved myself
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.