MSSQL PHP connection

Hello everyone. I am attempting to connect to a MSSQL server 2008 R2 server at work. I am getting an error when I try to connect to it. I just installed PHP on the server yesterday and it will show the PHP files with no problem, just will not allow me to run anything that deals with the SQL Server. I am getting the error:
Fatal error: Call to undefined function mssql_connect() in C:\Inetpub\wwwroot\msag\includes\db\connect.php on line 5

Conenction Code:
[php]<?php
error_reporting(E_ALL); ini_set(‘display_errors’, ‘1’);

$connect_error = (‘DB connection error.’);
mssql_connect (‘hostname’, ‘username’, password);
mssql_select_db (‘database’) or die ($connect_error);
?>[/php]

Any advice would be greatly appreciated.

You need to make sure that your work allows external connections and probably need to have your ip whitelisted. right now, the firewall is probrably refusing the connection.

I will check to make sure. I am, however, running this particular script on the actuall webserver istelf though. Would that cause a problem with the connection?

Have you enabled these functions in the php.ini?

http://www.php.net/manual/en/mssql.installation.php

There is also a PDO interface for MSSQL

http://www.php.net/manual/en/ref.pdo-dblib.php

Thank you guys for taking your time to help me. It is functional now. Turns out that there were about 800 libraries that needed to still be installed and turned on in my ini file. Finally got it working though. Thank you guys a bunch :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service