tags:

views:

820

answers:

1

I have, as best as I can manage, set up IIS (6.0), PHP (5.2.8) and MySQL (5.1.30) on Windows Server 2003, with all the involved mucking about (I think) in IIS and PHP to get things talking to each other.

PHP does work - however, I cannot use the mysql or mysqli libraries from a PHP page. Fatal error: Class 'mysqli' not found in...
Fatal error: Call to undefined function mysql_connect() in...

Information relating to MySQL or MySQLi does not appear when using phpinfo() in a PHP page.

However, when I invoke PHP from the command line, such as

> php -r phpinfo()

Information relating to MySQL and MySQLi does appear in the output from that.

Restarting IIS or the OS does not produce further effect. I have only one php.ini file, in the PHP root directory.

Do I need to connect MySQL to IIS somehow as well, or is there another problem?

+3  A: 

The php.ini file used for command-line usage of PHP may be different from the php.ini used by the web server. You should get phpinfo() information by putting a small PHP script under your web server's document space:

<?php
phpinfo();
?>

Open this PHP script by using your browser to request that PHP script via an URL to your web server. That will tell you what the web server thinks is your PHP configuration.

Also remember that you need to restart the web server for edits to php.ini to take effect. It only reads the php.ini when the web server starts.

There are numerous places the php.ini file that your IIS instance is using might live. See http://php.net/manual/en/configuration.php or http://www.iis-aid.com/articles/how_to_guides/where_php_ini_is_loaded_from for details.

Look at the output of phpinfo() when viewed in your browser, and look for the item "Loaded Configuration File".

Bill Karwin
Yes, I have been restarting the server regularly. The problem is, using phpinfo() as above returns different results than on the command line - and so MySQL works from the PHP command line but *not* from web pages. I have only one php.ini file, in the PHP root directory.
Jivlain
Yep, checking the location of the ini file did it - turns out it wasn't finding it. I put a copy in C:\Windows, and it worked :)
Jivlain