Connecting Tech Pros Worldwide Help | Site Map

mssql_connect not defined on MS Windows w/ IIS

Member
 
Join Date: Jul 2006
Posts: 89
#1: May 24 '07
Hello

I have problems connecting to my MSSQL through php.

I have a microsoft windows server 2003, web edition with php5 installed and Microsoft SQL Server: SQL Server 2005 Express Edition as my platform.

my connection string is as follows:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     $conn = mssql_connect('212.97.133.11','baconso_flemming','mypassword');
  3.     mssql_select_db('Baconso_flemming',$conn);
  4. ?>
  5.  
I get the following error message:

Fatal error: Call to undefined function mssql_connect() in C:\Inetpub\wwwroot\connopenphp.inc on line 2

I have done all the usual things that has to be done in order to get mssql to work with php such as removing the ';' from the extension=php_mssql.dll in my php.ini file.

I have downloaded the proper version of ntwdblib.dll (vers. 2000.80.194.0) and copied certain files to windows/system32 directory such as the ntwdblib.dll file and the php_mssql.dll file.

When i run a little file i made called info.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. phpinfo();
  4.  
  5. ?>
  6.  
I can't see any information about mssql in the description that appears on the screen.

I also did another little file:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if (function_exists('mssql_query')) {
  3.     echo "MSSQL functions are available.<br />\n";
  4. } else {
  5.     echo "MSSQL functions are not available.<br />\n";
  6. }
  7. ?>
it returned: MSSQL functions are not available.

Can anyone help me get my connection to work???????

Any ideas are more than welcome.........
tolkienarda's Avatar
Needs Regular Fix
 
Join Date: Dec 2006
Posts: 316
#2: May 24 '07

re: mssql_connect not defined on MS Windows w/ IIS


what php install are you using WAMP, some IIS install or is it on an apache web server

here is what i always use

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $host="localhost"; // Host name.
  3. $db_user="user"; // MySQL username.
  4. $db_password="pass"; // MySQL password.
  5. $database="dbname"; // Database name.
  6. $ambi = mysql_pconnect($host, $db_user, $db_password) or trigger_error(mysql_error(),E_USER_ERROR);
  7. ?>
  8.  
and i always use that then on the page i call that from i use the

Expand|Select|Wrap|Line Numbers
  1. <?
  2.  include 'connect.php';
  3.  mysql_select_db($database, $ambi);
  4.  ?>
  5.  
eric
Member
 
Join Date: Jul 2006
Posts: 89
#3: May 24 '07

re: mssql_connect not defined on MS Windows w/ IIS


I do not use apache server. I use the built in IIS version 6. In php i selected IIS ISAPI module when installing.

I tried your code suggestion, but it was the same.
Motoma's Avatar
Moderator
 
Join Date: Jan 2007
Location: Maine, USA
Posts: 2,904
#4: May 24 '07

re: mssql_connect not defined on MS Windows w/ IIS


Did you try starting the IIS service after making the changed to php.ini?

Have you gotten any error messages from IIS?

Is php loading the proper .ini file?
Member
 
Join Date: Jul 2006
Posts: 89
#5: May 24 '07

re: mssql_connect not defined on MS Windows w/ IIS


I have tried restarting the IIS service after making changes to the php file.

I haven't gotten any error messages from the IIS,only the error message before mentioned.

I am loding the file php.ini
Motoma's Avatar
Moderator
 
Join Date: Jan 2007
Location: Maine, USA
Posts: 2,904
#6: May 24 '07

re: mssql_connect not defined on MS Windows w/ IIS


What I meant was this: modify a value in php.ini that is coming up correctly in phpinfo() and check to see if that change was reflected in phpinfo(). If not, you may have your path incorrectly set.
Motoma's Avatar
Moderator
 
Join Date: Jan 2007
Location: Maine, USA
Posts: 2,904
#7: May 24 '07

re: mssql_connect not defined on MS Windows w/ IIS


Quote:

Originally Posted by tolkienarda

what php install are you using WAMP, some IIS install or is it on an apache web server

here is what i always use

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $host="localhost"; // Host name.
  3. $db_user="user"; // MySQL username.
  4. $db_password="pass"; // MySQL password.
  5. $database="dbname"; // Database name.
  6. $ambi = mysql_pconnect($host, $db_user, $db_password) or trigger_error(mysql_error(),E_USER_ERROR);
  7. ?>
  8.  
and i always use that then on the page i call that from i use the

Expand|Select|Wrap|Line Numbers
  1. <?
  2.  include 'connect.php';
  3.  mysql_select_db($database, $ambi);
  4.  ?>
  5.  
eric

This will not help because the OP is trying to use MSSQL instead of MySQL.
Member
 
Join Date: Jul 2006
Posts: 89
#8: May 24 '07

re: mssql_connect not defined on MS Windows w/ IIS


I have to .ini files. One named php.ini-dist and an other named php.ini-recommended.

Tried changing something in both of them, but the change didn't appear in the info.php file. Strange!

Any idea why this occurs......................?
Motoma's Avatar
Moderator
 
Join Date: Jan 2007
Location: Maine, USA
Posts: 2,904
#9: May 25 '07

re: mssql_connect not defined on MS Windows w/ IIS


Quote:

Originally Posted by printline

I have to .ini files. One named php.ini-dist and an other named php.ini-recommended.

Tried changing something in both of them, but the change didn't appear in the info.php file. Strange!

Any idea why this occurs......................?

Because you are not changing php.ini which happens to be the file PHP is looking for.
You need to read through the PHP installation instructions to find out how to set up the config file and the system paths.
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#10: May 25 '07

re: mssql_connect not defined on MS Windows w/ IIS


Changed thread title to better match thread contents.
Member
 
Join Date: Jul 2006
Posts: 89
#11: May 25 '07

re: mssql_connect not defined on MS Windows w/ IIS


that did it........

Thanks a lot.......
Motoma's Avatar
Moderator
 
Join Date: Jan 2007
Location: Maine, USA
Posts: 2,904
#12: May 25 '07

re: mssql_connect not defined on MS Windows w/ IIS


Quote:

Originally Posted by printline

that did it........

Thanks a lot.......

Awesome. Glad to help out.
Newbie
 
Join Date: Jul 2007
Posts: 1
#13: Jul 26 '07

re: mssql_connect not defined on MS Windows w/ IIS


Hope someone can give me a bit of advice here. We had a wonderfully working implemention of php / mssql / windows 2003. Following patch Tuesday the php scripts can no longer talk to the database. Much googling has not gleaned a result, apart from taking away the I am alone with this problem feeling. Apparently removing service pack 2 will fix the problem. Any better suggestions ?
Purple's Avatar
Moderator
 
Join Date: May 2007
Location: UK - North West
Posts: 385
#14: Jul 26 '07

re: mssql_connect not defined on MS Windows w/ IIS


Hi osmosis and welcome to TSDN !

for info you should post this in a new thread..

I am running a number of server 2003 with sp2 installed and php 5, mssql with IIS 6 - have not experienced any issues with the service pack

I suggest you open a new thread and we can discuss further.

Regards Purple
Reply