PHP5 and MYSQL will not communicate on iis6 server

I have been asked to develop a website on a windows 2003 server running iis6 and mysql 5.0.22 using php5 as the scripting language.

The server already has the mysql database on it and running.

I did a manual install of php5 which appears to be working without a problem.  Scripts run when uploaded in web pages etc and a page with phpinfo(); returns the expected php configuration and information.

Only problem is php will not talk to mysql.  Any attempt results in a blank page, no errors, just a blank page.

The phpinfo() does not show a mysql section.

What I have already figured out is :-

php5 doesn't come with mysql support enabled.  So I made the following changes:-

Edited php.ini so now contains:
extension_dir = "c:/inetpub/php/ext"

File Locations:
php_mysql.dll and php_mysqli.dll are in c:/inetpub/php/ext/
libmySQL.dll is in c:/inetpub/php/

Set the PATH variable to include c:/inetpub/php

When I couldn't get it working I dropped the two extension dll's into c:/windows/system32/ in the hope that might wake it up but to no avail.

Each time I make a change I request a reboot to ensure everything goes through.  PHP is defenitely reading the ini file because other settings like the includes directory that I set work fine and the mbstring.dll extension I enabled shows up in the phpinfo page.  Just no mysql.

So I am stuck.  Any help greatly appreaciated but it can't include.. use a different OS/scripting language/web server as it isn't my choice.


Tony Hyams

Who is Participating?
Robin HickmottConnect With a Mentor Software DeveloperCommented:
Quote possibly afaik libmysql.dll only comes with PHP or software that uses PHP ( zend Studio for example ) but I have never seen it dump stuff in system32. It differs depending on what API version is being used. I know with 5.2.0 they have recently made a new API for MySQL so its possible they dumped lots of redundant code. Mine is 1.40MB for comparison and working.

I would suggest deleting it as sometimes it will use this value first depending on your environment variables. You should use the one that comes with the PHP bundle your using to eliminate inconsistencies.

if you make a file called


and save it into your PHP folder you can execute

cd c:\Inetpub\php\
php phpinfo.php

and it will give a command line lisiting direct from PHP which should allow you to check if thats loading MySQL correctly.
Robin HickmottSoftware DeveloperCommented:

Will show you what php.ini file its using at the top of the script.

Remember as you are using windows you will need to set backslashes

extension_dir = "c:\inetpub\php\ext"

( the prior is for Apache/unix )

; UNIX: "/path1:/path2"
;include_path = ".:/php/includes"
; Windows: "\path1;\path2"


You do not need mysqli unless you are using it.

Make sure that php_mysql.dll is in the c:\inetpub\php\ext and that libmySQL.dll is in your php root ( All sounds ok there ).

PHPINFO() derives a lot of stuff if your not careful from the server ( Apache for example it picks the doc root up from the conf ) itself so double check what php.ini file it IS using by looking at the Configuration File (php.ini) Path setting in the PHPINFO() readout.
ahyamsAuthor Commented:
My bad.. so used to my unix server typed the slashes the wrong way around keep doing ls on my windows pc aswell.

Paths on the server and ini file have slashes the correct way around.

The ini file being used is what I'd expect :


So all that is correct.  The only extra thing I've discovered in that there is a libmysql.dll file in the system32 folder.  Its 228kb and I didn't put it there.  Could be a left over from a previous install perhaps ?

However the libmysql.dll file in my php directory is 1.4mb.  

a) Why such a big difference ?
b) If I replace the libmysql.dll in the system32 folder with my larger file will this only affect php and not mysql.

Reason for b is mysql is being used on the server so don't want to cripple it by accident but I am assured php is not being used except by myself.

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

ahyamsAuthor Commented:

rhickmott  .. ran the command as you suggested and added > info.txt to the end so I could read it all and cut and paste for here.

In the middle it has a mysql section:


MySQL Support => enabled
Active Persistent Links => 0
Active Links => 0
Client API version => 5.0.22

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


MysqlI Support => enabled
Client API library version => 5.0.22
Client API header version => 5.0.22
MYSQLI_SOCKET => /tmp/mysql.sock

Directive => Local Value => Master Value
mysqli.default_host => no value => no value
mysqli.default_port => 3306 => 3306
mysqli.default_pw => no value => no value
mysqli.default_socket => no value => no value
mysqli.default_user => no value => no value
mysqli.max_links => Unlimited => Unlimited
mysqli.reconnect => Off => Off

I have now got error reporting returning some results after I had it switched on using the ini file.  Fixed the obvious things like making sure passwords etc were correct.  But now get the error:

Fatal error: Call to undefined function mysql_pconnect() in <path editied by me>\gsgdb.php on line 9

Any ideas on where to proceed from here ?
Robin HickmottSoftware DeveloperCommented:
ok that proves that PHP is loading and using MySQL on its own without a Webbrowser.

run phpinfo.php() under the webbrowser and see if you have a MySQL section there it should say pretty much the same thing just with a pretty interface. If not then theres an issue with which config its loading under IIS.

Try whacking the php.ini into c:\windows\ and then seeing if you get any joy then.
ahyamsAuthor Commented:
Thanks  rhickmott,

I replaced the libmysql.dll in the system32 folder as you suggested in a previous post, rebooted  and now the mysql and mysqli sections are now showing under the web browser phpinfo.php().

Have tried various php recordset calls and displays which have all benn succesful :)  Problem solved.

It seems the wrong libmysql.dll file was the problem.  I assume because the system32 path appears before my mysql path in the enviroment variable it pulled that one instead of the dll in the php folder.  Just to clarify and add to my own understanding

Why did the php phpinfo.php run at the command line show mysql enabled while the browser run version didn't until I swapped the linmysql.dll file over ?

Anyway, thanks a lot your comments and suggestions really allowed me to work the problem where for the last two weeks I had just been staring at it.
Robin HickmottSoftware DeveloperCommented:
I think this is a PHP running under a Server Problem.

when you run PHP directly via the shell prompt it checks the current directory first "." and then if it has no joy goes looking in the system path. For some reason unknown to me I had the same problem as you when switching to 5.2.0 if there are files in c:\windows is will insist on using them over the c:\php\ ones when run via Apache but NOT from the PHP Console which was most odd.

Whether this is a 5.2.0 bug or a new feature they have introduced im not sure. It seems more an issue that anything else I had to practically eliminate all traces of PHP from the C:\windows folder in order to get MySQL to work and even after that the server refuses to accept a PHP.INI file in Any location OTHER than c:\windows\ so basically my whole PHP installation is in the one folder except php.ini which is most annoying as its totally unnecessary and makes upgrading a pita as you have to remember its there.

Your best of if still possible having a play and try and get as much as possible of it to run from c:\inetpub\php to avoid any upgrade problems in the future (if possible) normally upgrading is as simple as downloading the zip and extracting it into your PHP folder and restarting but now when files are strewn here there and everywhere it makes it more difficult.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.