# Help!  PHP and MySQL with Windows IIS

**URL:** <https://boards.straightdope.com/t/help-php-and-mysql-with-windows-iis/522133>\
**Category:** Factual Questions\
**Created:** [December 22, 2009, 12:36am UTC](https://boards.straightdope.com/t/help-php-and-mysql-with-windows-iis/522133 "2009-12-22T00:36:50Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![JimOfAllTrades](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@JimOfAllTrades](https://boards.straightdope.com/u/JimOfAllTrades)\
**Post date:** [December 22, 2009, 12:36am UTC](https://boards.straightdope.com/t/help-php-and-mysql-with-windows-iis/522133/1 "2009-12-22T00:36:50Z")

</div>

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](http://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](http://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](http://ASP.net). I finally wound up uninstalling and re-installing IIS and [ASP.net](http://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. 🙂

---

<div class="post-metadata">

**Author:** ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)\
**Post date:** [December 22, 2009, 12:54am UTC](https://boards.straightdope.com/t/help-php-and-mysql-with-windows-iis/522133/2 "2009-12-22T00:54:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Mike.V](https://avatars.discourse-cdn.com/v4/letter/m/82dd89/32.png) [@Mike.V](https://boards.straightdope.com/u/Mike.V)\
**Post date:** [December 22, 2009, 12:56am UTC](https://boards.straightdope.com/t/help-php-and-mysql-with-windows-iis/522133/3 "2009-12-22T00:56:04Z")

</div>

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](http://php.net/manual/en/function.mysql-connect.php) 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()](http://us.php.net/manual/en/function.phpinfo.php) should output a bunch of MySQL data if it does)

---

<div class="post-metadata">

**Author:** ![JimOfAllTrades](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@JimOfAllTrades](https://boards.straightdope.com/u/JimOfAllTrades)\
**Post date:** [December 22, 2009, 1:54am UTC](https://boards.straightdope.com/t/help-php-and-mysql-with-windows-iis/522133/4 "2009-12-22T01:54:50Z")

</div>

> [@friedo](#):
>
> 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.

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.

> [@friedo](#):
>
> 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.

I’ll look and report.

> [@Mike.V](#):
>
> 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?

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.

> [@Mike.V](#):
>
> That aside, I haven’t used PHP with IIS but generally you specify the database connection details using a [mysql\_connect](http://php.net/manual/en/function.mysql-connect.php) call. I would try to find that in the code and verify that the connection details are correct.

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

> [@Mike.V](#):
>
> Other things to check:
> 
> - Is MySQL running?
> - Does PHP have the MySQL extension enabled?  
> ([phpinfo()](http://us.php.net/manual/en/function.phpinfo.php) should output a bunch of MySQL data if it does)

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?

---

<div class="post-metadata">

**Author:** ![Mike.V](https://avatars.discourse-cdn.com/v4/letter/m/82dd89/32.png) [@Mike.V](https://boards.straightdope.com/u/Mike.V)\
**Post date:** [December 22, 2009, 2:05am UTC](https://boards.straightdope.com/t/help-php-and-mysql-with-windows-iis/522133/5 "2009-12-22T02:05:23Z")

</div>

> [@RJKUgly](#):
>
> My php.ini file has the following:  
> 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.

---

<div class="post-metadata">

**Author:** ![JimOfAllTrades](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@JimOfAllTrades](https://boards.straightdope.com/u/JimOfAllTrades)\
**Post date:** [December 22, 2009, 2:18am UTC](https://boards.straightdope.com/t/help-php-and-mysql-with-windows-iis/522133/6 "2009-12-22T02:18:25Z")

</div>

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?

> [@Mike.V](#):
>
> 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.

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.?

---

<div class="post-metadata">

**Author:** ![JimOfAllTrades](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@JimOfAllTrades](https://boards.straightdope.com/u/JimOfAllTrades)\
**Post date:** [December 22, 2009, 2:21am UTC](https://boards.straightdope.com/t/help-php-and-mysql-with-windows-iis/522133/7 "2009-12-22T02:21:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JimOfAllTrades](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@JimOfAllTrades](https://boards.straightdope.com/u/JimOfAllTrades)\
**Post date:** [December 22, 2009, 4:58pm UTC](https://boards.straightdope.com/t/help-php-and-mysql-with-windows-iis/522133/8 "2009-12-22T16:58:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Mike.V](https://avatars.discourse-cdn.com/v4/letter/m/82dd89/32.png) [@Mike.V](https://boards.straightdope.com/u/Mike.V)\
**Post date:** [December 23, 2009, 12:59am UTC](https://boards.straightdope.com/t/help-php-and-mysql-with-windows-iis/522133/9 "2009-12-23T00:59:05Z")

</div>

Ok, well here’s where the [db code](http://svn.oscommerce.com/fisheye/browse/~raw,r=1845/osCommerce/branches/hpdl/oscommerce/includes/classes/database/mysql.php) can be found in OSCommerce but I think you may be digging too deep. It looks like OSCommerce has an [administration page](http://www.oscommerce.info/kb/osCommerce/Administration_Tool/Tools/177) 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](http://www.oscommerce.com/community/support).

---

<div class="post-metadata">

**Author:** ![JimOfAllTrades](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@JimOfAllTrades](https://boards.straightdope.com/u/JimOfAllTrades)\
**Post date:** [December 30, 2009, 11:43pm UTC](https://boards.straightdope.com/t/help-php-and-mysql-with-windows-iis/522133/10 "2009-12-30T23:43:46Z")

</div>

**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.
