Mssql connect to php

Good day!

I’m here again posting about my problem in the connection of mssql to php.

I have a problem in my connection in mssql to php. I tried my best to fix my problem. Here is some data I could give for better understanding.

I used:

SQL Server 2005 Express
SQL Server Management Studio Express
IIS 6.0
php 5.2.4

I configure my php.ini
I uncommented the following:

cgi.force_redirect = 0
doc_root = “C:\Inetpub\wwwroot”
mssql.secure_connection = On

I change my ntwdlib.dll version from 2000.2.8.0 to 2000.80.194.0 because I found out that my older version of ntwdblib.dll was not work in sql server 2005 so I search for a ntwdblib.dll version that work on sql server 2005. So I deleted the old version and I put the new version of ntwdblib.dll in Windows/System32, php folder, and in php/ext folder.

And this is my information in my SQL Server:

Server Type: Database Engine
Authentication: Windows Authentication
Username: MR\Administrator ----This username was hiding
Password: ----Password was hiding

I have a big question in my mind and it is what username and password I could use in php to connect in mssql if the username and password is hiding. I try to use the sa and its password, but I don’t know if it is right. And also I try the MR\Administrator as username and the password is blank, but sad to say still I can’t connect.

Here is my code:

//mssql.secure_connection = On
// Need to upload ntwdblib.dll from net
$myServer = “ISM\\SQLEXPRESS”; // host/instance_name
$myUser = “sa”; // username
$myPass = “xoxoxo&#8243;; // password
$myDB = “dbtest”; // database name
// connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die(“Couldn’t connect to SQL Server on $myServer”);
// select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
or die(“Couldn’t open database $myDB”);
echo “You are connected to the ” . $myDB . ” database on the ” . $myServer . “.”;

After I run this code, the result is:

Fatal error:Call to undefined function mssql_connect() in C:\Inetpub\wwwroot\ estconn.php on line 11

I don’t know what the problem is and what the configurations I need to do are.

I hope somebody can suggest or help me to fix my problem, because I really need to fix it.

Thank you in advance…

How can i use pdo?and what is the requirements and configuration i need to do?

If this is a new project and you aren’t far along I STRONGLY recommend using the PDO library instead of the mssql group of functions. It abstracts much of the particulars of the connection and will allow you to switch databases fairly easily in the future without rewriting the code. Aside from that it’s just plain easier to use PDO than the direct access functions it replaces. and for MS SQL

Is there actually a php_mssql.dll file in your extensions folder?
Are your other extensions loading up properly?
Did you check the event log for IIS startup errors?
Did you restart the webserver after updating your configuration (I’m not sure if this is necessary when using IIS)?

Make a one line php program
<?php echo phpinfo(); ?>

And access it via a browser. That will tell you which extensions are actually loaded.

It’s not seeing the mssql extension for some reason hence the undefined function message. once you get rid of the message then you can focus on the password problem.

The phpinfo screen will tell you which php.ini file is being used. You may have more than one on your system.

Yes, the php_mssql.dll is in my ext folder
How can i know if my other extension work properly?
Yes, i check my event log, and this si the information i got:

The Database Mirroring protocol transport is disabled or not configured.
Yes, i restarted my webserver after I updating my php.ini

I run the php info();
and i found out that mssql extension was not there and only the odbc was on the php info.

Using the usernmae and password are the big question in my mind, because I used windows authentication and the username is MRM\Administrator and it is hide and also the password is none and it is also hide. So I don’t know if what username I should use…Or should i used the sa username and the password xoxoxo.