Subscribe to this feed

Navigation

Recent Posts

Archive

Popular Tags

Click tag to retrieve blogs
  1. Excel (9)
  2. Oracle (6)
  3. csv (5)
  4. batch files (5)
  5. PHP (3)
  6. SQLPLus (3)
  7. VBA (3)
  8. Apache (3)
  9. DOS (3)
  10. SQL*Plus (3)
  11. Macro (3)
  12. bat (3)
  13. data migration (2)
  14. System Implementation (2)
  15. MySQL (2)
  16. Microsoft (2)
  17. Windows (2)
  18. new systems (2)
  19. SQL (2)
  20. Updates (1)
  21. Prince2 (1)
  22. MSDOS (1)
  23. Import file (1)
  24. ISERR (1)
  25. testing (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

Comment
 | Link | Back to top | del.icio.us digg it furl reddit

Using datetime stamp in MySQL query

Tuesday 16 Jan, 2007 - 18:59pm | 0 comments |

I would have to describe this as a hack rather than anything else as the convert function wouldn't work for me and date() is not supported, i.e. you can't use "SELECT date(timestamp_field) from db"; to extract only the date element; whereas you can use year(timestamp_field) or month(timestamp_field).

I needed to filter records based on the date, to extract rows from the table where the date was equal to today. The date field in the table was a datetime column. My workaround was to use the left function and extract the ten characters of the date which I could then compare to today as in the following.


$query = "SELECT title, contents FROM articles WHERE left(timestamp_field,10) = '$date'";

This worked. I don't think it's the elegant solution, alternatives welcomed.

Tags:SQL |MySQL |timestamp |date function

Comment
 | Link | Back to top | del.icio.us digg it furl reddit

© Eriginal Ltd 2011, all rights reserved