我收到此错误致命错误:在第 8 行的 /var/www/html/test1.php 中调用未定义函数 mysql_connect() 以获取以下代码:
<?php
$host = "localhost";
$user = "user12";
$pass = "34klq*";
ini_set ('display_errors', 1);
$r = mysql_connect($host, $user, $pass);
if (!$r) {
echo "Could not connect to server\n";
trigger_error(mysql_error(), E_USER_ERROR);
} else {
echo "Connection established\n";
}
echo mysql_get_server_info() . "\n";
mysql_close();
?>
我的系统中安装了 PHP、MYSQL、php-Mysql:
[root@localhost ~]# rpm -qa | grep mysql
php-mysql-5.3.3-3.el6_2.8.i686
mysql-devel-5.1.61-4.el6.i686
mysql-server-5.1.61-4.el6.i686
mysql-bench-5.1.61-4.el6.i686
mysql-libs-5.1.61-4.el6.i686
mysql-5.1.61-4.el6.i686
[root@localhost ~]# rpm -qa | grep php
php-common-5.3.3-3.el6_2.8.i686
php-5.3.3-3.el6_2.8.i686
php-mysql-5.3.3-3.el6_2.8.i686
php-cli-5.3.3-3.el6_2.8.i686
php-pdo-5.3.3-3.el6_2.8.i686
phpinfo() 的输出:http: //jsfiddle.net/nit8899/GZ4f7/
我还编辑了/etc/php.ini
文件:
extension=mysql.so
但即便如此,我也收到了这个错误。