# MSSQL PHP connection

**URL:** <https://www.phphelp.com/t/mssql-php-connection/18924>\
**Category:** General PHP Help\
**Created:** [November 16, 2012, 3:13pm UTC](https://www.phphelp.com/t/mssql-php-connection/18924 "2012-11-16T15:13:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![willscarlet](https://www.phphelp.com/letter_avatar_proxy/v4/letter/w/b5a626/32.png) [@willscarlet](https://www.phphelp.com/u/willscarlet)\
**Post date:** [November 16, 2012, 3:13pm UTC](https://www.phphelp.com/t/mssql-php-connection/18924/1 "2012-11-16T15:13:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![richei](https://www.phphelp.com/letter_avatar_proxy/v4/letter/r/e5b9ba/32.png) [@richei](https://www.phphelp.com/u/richei)\
**Post date:** [November 16, 2012, 3:34pm UTC](https://www.phphelp.com/t/mssql-php-connection/18924/2 "2012-11-16T15:34:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![willscarlet](https://www.phphelp.com/letter_avatar_proxy/v4/letter/w/b5a626/32.png) [@willscarlet](https://www.phphelp.com/u/willscarlet)\
**Post date:** [November 16, 2012, 4:48pm UTC](https://www.phphelp.com/t/mssql-php-connection/18924/3 "2012-11-16T16:48:19Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![m11](https://www.phphelp.com/letter_avatar_proxy/v4/letter/m/85f322/32.png) [@m11](https://www.phphelp.com/u/m11)\
**Post date:** [November 16, 2012, 5:02pm UTC](https://www.phphelp.com/t/mssql-php-connection/18924/4 "2012-11-16T17:02:04Z")

</div>

Have you enabled these functions in the php.ini?

[http://www.php.net/manual/en/mssql.installation.php](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](http://www.php.net/manual/en/ref.pdo-dblib.php)

---

<div class="post-metadata">

**Author:** ![willscarlet](https://www.phphelp.com/letter_avatar_proxy/v4/letter/w/b5a626/32.png) [@willscarlet](https://www.phphelp.com/u/willscarlet)\
**Post date:** [November 19, 2012, 12:57pm UTC](https://www.phphelp.com/t/mssql-php-connection/18924/5 "2012-11-19T12:57:31Z")

</div>

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 🙂
