[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now


PHP5 and MYSQL will not communicate on iis6 server

Posted on 2006-11-09
Medium Priority
Last Modified: 2008-02-01
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

Question by:ahyams
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
LVL 13

Expert Comment

ID: 17907296

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.

Author Comment

ID: 17907578
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.

LVL 13

Accepted Solution

rhickmott earned 2000 total points
ID: 17907653
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.
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 17910913

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 ?
LVL 13

Expert Comment

ID: 17911117
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.

Author Comment

ID: 17913115
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.
LVL 13

Expert Comment

ID: 17913408
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.

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question