Link to home
Start Free TrialLog in
Avatar of ahyams
ahyams

asked on

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"
extension=php_mysql.dll
extension=php_mysqli.dll

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.

Thanks

Tony Hyams

Avatar of Robin Hickmott
Robin Hickmott

php_info()

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"

================
extension=php_mysql.dll
================

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.
Avatar of ahyams

ASKER

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 :

C:\Inetpub\php\php.ini

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.

ASKER CERTIFIED SOLUTION
Avatar of Robin Hickmott
Robin Hickmott

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ahyams

ASKER

OK...

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

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

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 ?
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.
Avatar of ahyams

ASKER

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