Help! PHP and MySQL with Windows IIS

Here is my tale of woe.

I’m in charge of a website written in PHP/HTML and running a MySQL database for the e-store. This was written by a third party who is no longer available.

The server is running W2k3 Server, and IIS 6. I also have a couple of other straight HTML websites and my email server (MailEnable) running on the same box. MailEnable uses ASP.net to run it’s webmail application.

Note that I’m the network, AS400/PC programmer, and admin guy. My HTML and ASP (classic) skills are medium to low, but my PHP, MySQL, and ASP.net skills are pretty much zilch.

A couple of weeks ago all the websites on this box (even the ones written in straight HTML!) started showing the message “Service Unavailable” for every page, which I traced to some error in ASP.net. I finally wound up uninstalling and re-installing IIS and ASP.net. This fixed the error with all the websites except the one written in PHP. It just gave me a “Page not Found” error. So I figured this is because PHP is no longer hooked up correctly to my site in IIS.

I then re-installed PHP 5 (5.2.1.1) (which may have been a mistake, I think it overwrote my PHP.ini file). But it didn’t change anything in IIS. So after screwing around a bit I manually created a “Service” under IIS called PHP, with the only required file being php5isapi.dll in the folder where PHP is installed (this folder is also in the windows path). Next I went to the properties for the website using PHP and added an ISAPI Filter, also called PHP, and set the executable to the same DLL.

Now the PHP website will display pages. But I have no idea if I’ve done those things correctly or completely.

But now if you click on any link that needs to get something from the database (such as adding a product to the shopping cart) it fails. I’m now assuming that PHP is no longer correctly talking to the MySQL database, probably because I overwrote the damn ini file when I reinstalled PHP.

So, can anybody tell me in short words how to make PHP talk to MySQL? And how about the way I manually put the PHP service and ISAPI Filter into IIS? Is that the correct way?

Or if someone who is knowledgeable about IIS/PHP/MySQL wanted to volunteer to log onto my server and take a look at things, I’ll set up a login via RDP, and I’d be very grateful. :slight_smile:

I’ve never done anything with PHP on Windows, but on Unix-type versions, the MySQL API is a separate module that has to installed and linked to PHP.

If you take a look at your web server’s error logs (IIS has those, right?) you may be able to glean some more information about what’s going on.

We really need more information than “my database doesn’t work” to help you. Perhaps a link to the page? Or the exact text of the error?

That aside, I haven’t used PHP with IIS but generally you specify the database connection details using a mysql_connect call. I would try to find that in the code and verify that the connection details are correct. Other things to check:

  • Is MySQL running?
  • Does PHP have the MySQL extension enabled? (phpinfo() should output a bunch of MySQL data if it does)

My php.ini file has the following:

[PHP_MYSQL]
extension=php_mysql.dll

When I ran the install for PHP, I specified that it should install the MySQL extension, I assume the above is the result of that.

I’ll look and report.

I’m not seeing an error page (although there may be something in the web logs as noted above, I’ll check those) but when I click on an item to add to the cart, I get a page displayed by the store that just says that product can’t be found.

A search of all files in the website doesn’t find this string in any of them.

The MySQL service is running, and I believe the extension is enabled (see above).

I created a simple PHP file, copied in the phpinfo code from the website you linked, and it returns this information in the MySQL section:

Active Persistent Links 0
Active Links 0
Client API version 5.0.51a

Directive Local Value Master Value
mysql.allow_persistent On On
mysql.connect_timeout 60 60
mysql.default_host no value no value
mysql.default_password no value no value
mysql.default_port no value no value
mysql.default_socket no value no value
mysql.default_user no value no value
mysql.max_links Unlimited Unlimited
mysql.max_persistent Unlimited Unlimited
mysql.trace_mode Off Off

My guess is the default, host, password, etc. having no value are the problem?

That sounds reasonable to me, especially since you couldn’t find an explicit mysql_connect. Assuming that’s correct, you’ll either need to find your login information somewhere or get root access to MySQL to change the login.

It doesn’t help now of course, but in the future I would use mysql_connect to separate the application-specific settings from the server configuration.

Some additional information:

The estore is a freebie called osCommerce 2.2, and it is osCommerce that uses the MySQL for its tables.

Could osCommerce have ini files somewhere that have the connect information? Anybody know anything about this software?

When you say “get root access”, this is a box I own, and I am the administrator. I have access to anything on the machine. Is there something I can run in MySQL to tell me the MySQL users, passwords, etc.?

And by the way, thanks very much both of you for the help!

A little bump to see if the earlier crowd has any ideas.

Ok, well here’s where the db code can be found in OSCommerce but I think you may be digging too deep. It looks like OSCommerce has an administration page that you can log in to and use to manage the site. I would look there first. If the whole database was down I doubt you could even make it to the “product not found page.” In any case, you’ll probably find better help on one of their forums.

Mike.V, I’m sorry I didn’t see this last week, I must have screwed up my subscription t the thread and didn’t get notified.

Thanks very much for the response, I’ll try the admin page you mention, and failing that I’ll hit the osCommerce forum.

Thanks again.