Fatal error: Call to undefined function mysql_connect()
Posted: Mon Mar 30, 2009 7:29 am
I created a php file as following:
When I call this file by browser, it shows:
Connected successfully
However when I use the php command line:
It shows the following error:
Fatal error: Call to undefined function mysql_connect() in /var/www/tmp/test.php on line 2
The phpinfo shows:
Could anybody help me solve this problem. Thanks for any advance.
Code: Select all
<?php
$link = mysql_connect('localhost', 'admin', '123456');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>Connected successfully
However when I use the php command line:
Code: Select all
/usr/local/bin/php -f /var/www/tmp/test.phpIt shows the following error:
Fatal error: Call to undefined function mysql_connect() in /var/www/tmp/test.php on line 2
The phpinfo shows:
Code: Select all
mysql
MySQL Support enabled
Active Persistent Links 0
Active Links 0
Client API version 5.0.67
MYSQL_MODULE_TYPE external
MYSQL_SOCKET /var/run/mysqld/mysqld.sock
MYSQL_INCLUDE -I/usr/include/mysql
MYSQL_LIBS -L/usr/lib -lmysqlclient_rCould anybody help me solve this problem. Thanks for any advance.