I have a development box running Windows XP, Apache 2.2.15 Mysql and PHP 5.2.6

About a month ago I updated the Apache to the latest version and it went swimmingly. I am not having the same success with upgrading PHP to the latest version.

I backed up my PHP directory and then deleted it. Used the Windows Installer for PHP 5.3.2, installed as an Apache 2.2.X module. I can get "Hello World" and phpinfo() to come up but cannot get mysql to connect. I have the extension un-commented in the php.ini and shouldn't really have to touch the Apache httpd.conf file since I didn't change the directory of PHP.

Not sure what I'm doing wrong here. I have to get this right and then upgrade the Live Server too so I want to get this down pat.

I've tried to use installation guides on the web with no luck. Any info pertaining to this problem would be great. I'm also afraid that the other PHP modules may not load but cannot really tell anything past mysql not working.

This is what appears in phpinfo()

mysqlnd enabled
Version     mysqlnd 5.0.7-dev - 091210 - $Revision: 294543 $
Compression     supported
Command buffer size     4096
Read buffer size    32768
Read timeout    31536000
Collecting statistics   Yes
Collecting memory statistics    No 

I cannot figure out how to enable mysql, mysqli etc. though they seem to be installed.

  • 1
    Could you please post the specific PHP error messages you're getting. – Ben Pilbrow May 18 '10 at 22:20
  • 1
    Does phpinfo() output include sections called mysql, mysqli or pdo_mysql? – Nate May 18 '10 at 22:59
  • Fatal error: Call to undefined function mysql_connect() – mcondiff May 19 '10 at 13:57

Since you're getting the error Fatal error: Call to undefined function mysql_connect(), that means that the MySQL extension is not being loaded by PHP. This is configured in your php.ini file.

To find the location of your php.ini file, create a php file and in it paste the following.
<?php phpinfo(); ?>

On the page (near the top) you will have an entry labelled Loaded Configuration File. Check this file that has been loaded is actually the one that you expect it to load. Personally, mine loads from C:/php/php.ini, but if I recall correctly when I was initially setting it all up, it was trying to read from C:/Windows/php.ini (which didn't exist) so was using defaults for everything, which didn't include some of the extra modules I wanted.

Open that file with your favourite text editor and in there should be several lines beginning extension=xxxxx.dll.

Look through the list of modules and check that extension=php_mysql.dll is listed and the first character of the line is not a semi-colon (;). If it's not listed, just add it to the list - if it has the semi-colon at the beginning of the line, remove the semi-colon and save the file.

You should also check the value of extension_dir, and also verify this path exists on the filesystem. This should be something similar to c:/php/ext.

Once you've made changes to the php.ini file, you will need to restart Apache so the configuration file is re-read.

Once you've restarted Apache, refresh your phpinfo page and check that it has sections listed for MySQL.

You might also want to check if C:\php is included in your PATH environment variable.

If you're still having issues, try firing up a command line and cd to C:\php and type php -v. This will output the PHP version, but will often spit out more error messages than are shown when loading a web page

  • Configuration File (php.ini) Path C:\WINDOWS Loaded Configuration File C:\PHP\php.ini There is no php.ini in Windows directory. I instructed PHP to install mysql, mysqli etc. However, it does not show up in the phpinfo(). Any ideas? – mcondiff May 19 '10 at 20:38
  • It says cannot load extensions from Program Files\PHP which is wrong. Where do I specify all this? My PHP directory is C:\PHP? – mcondiff May 19 '10 at 21:03
  • Please see the update to my answer (check extension_dir and the bottom 2 lines) – Ben Pilbrow May 19 '10 at 21:03
  • There's a directive in php.ini called extension_dir - check that, change to C:\php\ext and restart the Apache service. Sorry, I deleted my other comment and added it into my answer, so the comments are a bit weirdly ordered now! – Ben Pilbrow May 19 '10 at 21:05
  • Found it. Extension directory was wrong in PHP.ini. Thank You – mcondiff May 19 '10 at 21:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.