Subscribe to this feed


Recent Posts


Popular Tags

Click tag to retrieve blogs
  1. Excel (9)
  2. Oracle (6)
  3. batch files (5)
  4. csv (5)
  5. Macro (3)
  6. bat (3)
  7. PHP (3)
  8. SQLPLus (3)
  9. VBA (3)
  10. Apache (3)
  11. DOS (3)
  12. SQL*Plus (3)
  13. SQL (2)
  14. data migration (2)
  15. System Implementation (2)
  16. MySQL (2)
  17. Microsoft (2)
  18. Windows (2)
  19. new systems (2)
  20. laptops (1)
  21. Products (1)
  22. DataType (1)
  23. UK Post Codes (1)
  24. Linux (1)
  25. Mod Rewrite (1)

php5 extensions directory and mysql undefined function

Monday 21 Jan, 2008 - 17:58pm | 0 comments |

Call to undefined function mysql_connect() or have a php.ini file which doesn't seem to behave, i.e. the extension_dir seems to have a mind of its own so the MySQL extensions aren't loading? 

I was having this problem on a new install of Apache 2.2.8, PHP 5.2.5, and MySQL 5.1.22 on Windows Vista Home Premium. 

My first mistake downloading only the PHP installer. This does not include the extensions. Download the zip package and copy the extensions folder from it into your PHP directory. Edit php.ini, go to the dynamic extensions section and add the following

extension = php_mysqli.dll;
extension = php_mysql.dll;

Make sure the extensions directory is set to the correct path. Reboot Apache...

I was still getting the same error - call to undefined function. I spent a few hours on google looking for the answer. This included copying php.ini, php_mysql.dll. php_mysqli.dll and libmysql.dll into and out of various directories including c:\windows and c:\windows\system 32. None of which worked. 

Back to the drawing board. phpinfo records the extensions path as being c:\php5. There's the answer. There is no such folder and this isn't where extension_dir is pointed in php.ini? Why would it be picking up this directory?

As a shortcut I create the folder and copy the extensions into it. It still doesn't work. I edit php.ini and change the slashes on the extensions directory and try various symantics

  • c:\program files\php\ext
  • c:/program files/php/ext
  • c:/program files/php/ext/

Reboot Apache each time but it still doesn't work and the extension directory in phpinfo is still pointing at the spectral c:\php5. Where is it picking this up?  I find a few forums suggesting it's a permissions problem. I disable all security settings, turn off User Account Control and open all access to php.ini. It doesn't make a difference, I still get the same message. 

Back to basics. I open the Apache configuration file. It turns out the solution is a lot simpler. PHPIniDir in httpd.conf is incorrect. It's pointing to a folder which doesn't exist so windows has been using defaults to locate the files. Change the folder name to the correct path "C:\Program Files\PHP\" including the closing slash. Restart Apache. Eureka.

I'm not the first person to have this problem. I won't be the last, if you stumble on this post while you're having problems with an install concentrate on phpinfo,  particularly the Loaded Configuration File and the extension_dir, and yes double check the settings on your web server.

Tags:PHP |Apache |MySQL |Vista |MySQL undefined function

 | Link | Back to top | digg it furl reddit

© Eriginal Ltd 2011, all rights reserved