MySQL extension of PHP not working
Posted
by
Víctor
on Server Fault
See other posts from Server Fault
or by Víctor
Published on 2012-07-03T08:40:25Z
Indexed on
2012/07/03
9:17 UTC
Read the original article
Hit count: 301
In a Debian server, and after intallation and removal of SquirrelMail (with some downgrade and upgrade of php5, mysql...) the MySQL extension of PHP has stopped working.
I have php5-mysql installed, and when I try to connect to a database through php-cli, i connect successfully, but when I try to connect from a web served by Apache I cannot connect.
This script, run by php5-cli:
echo phpinfo();
$link = mysql_connect('localhost', 'user, 'password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
Prints the phpinfo, which includes "/etc/php5/cli/conf.d/mysql.ini", and also the MySQL section with all the configuration: SOCKET, LIBS... And then it prints "Connectes successfully".
But when run by apache accessed by web browser, it displays the phpinfo, which includes "/etc/php5/apache2/conf.d/mysql.ini", but has the MySQL section missing, and the script dies printing "Fatal error: Call to undefined function mysql_connect()".
Note that both "/etc/php5/cli/conf.d/mysql.ini" and "/etc/php5/apache2/conf.d/mysql.ini" are in fact the same configuration, because I have in debian the structure:
/etc/php5/apache2
/etc/php5/cgi
/etc/php5/cli
/etc/php5/conf.d
And both point at the same directory:
/etc/php5/apache2/conf.d -> ../conf.d
/etc/php5/cli -> ../conf.d
Where /etc/php5/conf.d/mysql.ini consists of one line:
extension=mysql.so
So my question is: why is the MySQL extension for PHP not working if I have the configuration included just in the same way as in php-cli, which is working?
Thanks a lot!
© Server Fault or respective owner