By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,905 Members | 2,083 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,905 IT Pros & Developers. It's quick & easy.

mssql_connect not defined on MS Windows w/ IIS

P: 89
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.........
May 24 '07 #1
Share this Question
Share on Google+
13 Replies


tolkienarda
100+
P: 316
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
May 24 '07 #2

P: 89
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.
May 24 '07 #3

Motoma
Expert 2.5K+
P: 3,235
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?
May 24 '07 #4

P: 89
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
May 24 '07 #5

Motoma
Expert 2.5K+
P: 3,235
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.
May 24 '07 #6

Motoma
Expert 2.5K+
P: 3,235
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.
May 24 '07 #7

P: 89
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......................?
May 24 '07 #8

Motoma
Expert 2.5K+
P: 3,235
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.
May 25 '07 #9

pbmods
Expert 5K+
P: 5,821
Changed thread title to better match thread contents.
May 25 '07 #10

P: 89
that did it........

Thanks a lot.......
May 25 '07 #11

Motoma
Expert 2.5K+
P: 3,235
that did it........

Thanks a lot.......
Awesome. Glad to help out.
May 25 '07 #12

P: 1
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 ?
Jul 26 '07 #13

Purple
Expert 100+
P: 404
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
Jul 26 '07 #14

Post your reply

Sign in to post your reply or Sign up for a free account.