apache can't connect to mysql

I'm getting the following in /var/log/httpd-error.log:
Code:
PHP Fatal error:  Call to undefined function mysql_connect() in /...

mysql seems to be installed (from php_info()):
Code:
mysqlnd
mysqlnd	enabled
Version 	mysqlnd 5.0.8-dev - 20102224 - $Id: 65fe78e70ce53d27a6cd578597722950e490b0d0 $
Compression 	not supported
SSL 	supported
Command buffer size 	4096
Read buffer size 	32768
Read timeout 	31536000
Collecting statistics 	Yes
Collecting memory statistics 	No
Tracing 	n/a


pkg_info|grep php|grep mysql:
Code:
# pkg_info | grep php | grep mysql
php53-mysql-5.3.15  The mysql shared extension for php
 
Make sure its loaded in extensions.ini for php to be able to use it.

Try the following command it should tell you where extensions.ini is located.

# php --ini

You should extension=mysql.so on one line.
 
Code:
# php --ini
Configuration File (php.ini) Path: /usr/local/etc
Loaded Configuration File:         (none)
Scan for additional .ini files in: /usr/local/etc/php
Additional .ini files parsed:      /usr/local/etc/php/extensions.ini,
/usr/local/etc/php/php.ini
 
As chatwizrd suggested, you should open /usr/local/etc/php.ini and see if you find an uncommented line reading:

Code:
extension=mysql.so

<offtopic>@SirDice, which is the icon for port-tags?</offtopic>
 
Just a quick note that when using the port, the extensions are added to /usr/local/etc/php/extensions.ini so you should look there for the mysql.so entry, not the php.ini file. (Of course if it's already in there, it could suggest that the problem is that php is not reading this file, however your --ini output suggests php is configured to look there)

Going back to the original post, I don't think the mysqlnd entry in your php_info output shown confirms that these functions will be available. mysql_connect() is provided by the mysql extension, not mysqlnd. You should see something like the following in php -i output if the correct extension is loaded (in addition to the mysqlnd section):

Code:
mysql

MySQL Support => enabled
Active Persistent Links => 0
Active Links => 0
Client API version => mysqlnd 5.0.8-dev - 20102224 - $Revision: 310735 $
 
Thanks. Actually rebooting solved the issue. I'm guessing that restarting apache might have also done the trick, but I'm not sure. This all happened after a port update that included php, mysql and apache22 threaded.

Code:
mysql

MySQL Support => enabled
Active Persistent Links => 0
Active Links => 0
Client API version => mysqlnd 5.0.8-dev - 20102224
 
Back
Top