Question : IIS generates 500 Internal Server Error when using PHP to connect to MySQL

Hi folks,

I've been given a bit of development space on a server in our office here (instead of developing locally like I've been doing so far) and I'm having some issues with the configuration.

Quick specs are:

WIndows Server 2008 (32 bit)
IIS 7
PHP 5.3.1
MySQL 5.1.41

The IIS service was installed for me but I've installed php (non-thread safe vc9 msi installer) and MySQL (again with the msi installer).

PHP works fine and displays a phpinfo() page (/phpinfo.php) without any trouble and mysql is enabled.  I can use the command line & GUI tools to access mysql so I know it's running.  When I try to get php to connect to mysql using the following code (/db_test.php), it throws the 500 internal server error ("There is a problem with the resource you are looking for, and it cannot be displayed.").

IIS is configured to deal with php using fastCgi if that makes any difference.

Any help would be appreciated.  I've done this quite a few times before but always used apache as the webserver and never had any issues.

Cheers,
Kevin
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:

           

Answer : IIS generates 500 Internal Server Error when using PHP to connect to MySQL

127.0.0.1 vs localhost
- Not sure if this is the case here, but there are situations where connections look for a "computer on a domain" which implies that there is a dot in the computername.
- In you case, this might be a solution or a problem: if your computer name has a dot in it, try using this name.

Note that if you intend your app and mysql to be ALWAYS on the same machine, 127.0.0.1 is not a bad choice

Note2: you might edit / create your LMHOSTS file on the server so that you can create an entry like local.host to be another alias to 127.0.0.1... but I think this should be avoided... if the file is deleted or the app moved, it will mysteriously stop working.
Random Solutions  
 
programming4us programming4us