Forum Moderators: coopster

Message Too Old, No Replies

IIS - Call to undefined function mysql connect()

PHP and mysql

         

wormtowndj

10:55 pm on Dec 2, 2011 (gmt 0)

10+ Year Member



I am missing something, and I've spent two days trying to find what it is through every google search I could conjure. I apologize if you think this would be better on a different forum, but here goes:

I am moving my company intranet to a new server, and within the intranet is a PHP bulletin board (phpBB3), which has worked great on the old server for 2 years. I have changed none of the code which still works on the old server. The Intranet is at "http://intranet/" and the bulletin board is at "http://intranet/phpbb3/". The bulletin board is working fine on both old and new server, except for ONE thing. On my homepage, "http://intranet/index.html", I pass control to a PHP program which should return the top 10 recent posts to the forum:
<?php
include($_SERVER['DOCUMENT_ROOT']. '/phpbb3/recentposts.php');
?>

The PHP is being called fine, but I receive an error when recentposts.php gets to this line:
$link = mysql_connect("$dbhost", "$dbuser", "$dbpasswd");

The error is
Fatal error: Call to undefined function mysql_connect() in C:\Intranet\phpBB3\recentposts.php on line 17

Now, if I go directly to the page "http://intranet/phpbb3/recentposts.php", it retrieves my top 10 recent posts just fine. So it's somehow dying in the process of the connection to mysql from php from within html. I confess I am stumped.

I've checked every .ini file, the IIS setings, fastCGI...I am at a loss even where to look any more. Obviously I missed a setting somewhere, even though I can compare everything side by side to the old server. Anybody have any ideas what I might be missing?

By the way, I originally tried the newest versions of PHP and mysql, but gave up and am now trying a completely identical (and old) setup:
MS Server 2003 IIS6, PHP 5.2.9-2, fastCGI, mysql 5.0.51a
- Thank you

penders

10:50 am on Dec 3, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you change "index.html" to "index.php" does it make any difference?!

enigma1

3:17 pm on Dec 3, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've checked every .ini file

Do you have multiple php.ini files?

wormtowndj

5:15 am on Dec 4, 2011 (gmt 0)

10+ Year Member



Only one php.ini, but penders is on to something! When I change index.html to index.php, the page displays perfectly. That was a great test. What it means, though, still eludes me.

So, I again checked my Default Web Site Properties > Home Directory > Application Settings > Configuration, and I have Cache Isapi extensions checked and the .html extension has an Executable Path of c:\php\php5isapi.dll, limited to Get,Post. Script engine is checked. I double checked all of those IIS settings against the old server, and unless I'm missing something, they're identical.

I already feel better, but what's my next move, Penders?

penders

4:18 pm on Dec 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm not sure... your .php file by itself appeared to work OK, but the .html file did not get parsed correctly, although PHP appeared to be doing something with it. I was really thinking from an Apache perspective as I haven't used IIS for such a long time. In order to get PHP to parse the .html file you need to instruct the server to do so... are there different ways in which you can do this, as there seems to be with Apache (AddHandler, AddType, ...)?

Are .html files set to be parsed by some other server-side engine, such as SSIs perhaps, that .php files are not?

Compare the output of phpinfo() in index.php and index.html. Any differences?

wormtowndj

5:13 pm on Dec 4, 2011 (gmt 0)

10+ Year Member



Wow, I cannot thank you enough. Your suggestion to compare the phpinfo was the key. I created an identical copy of phpinfo.php called phpinfo.html and started comparing side by side. I noticed right away that phpinfo.html lists ISAPI as the Server API, while the php version uses CGI/FastCGI. More telling was that, while both list C:\WINDOWS as the Configuration path, only the phpinfo.php actually found my configuration file, which I have at C:\php\php.ini. The phpinfo.html listed "(none)" under "configuration file". I guess including c:\php in the Path wasn't enough. So I copied php.ini to the C:\Windows directory, and smooth sailing!

Still unexplained is why this worked on the old server. Clearly, I missed some setting somewhere, because it really goes against my sense of order to maintain php.ini in two different places. But realistically, I've never touched that file in 2 years anyway. If someone has a suggestion about what I did wrong, I'd love to hear it, but for now I have everything working, and I am MOST appreciative.