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
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.
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.
© Eriginal Ltd 2011, all rights reserved