Fatal error: Call to undefined function mysql_connect()

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
haughtycool
Forum Newbie
Posts: 1
Joined: Mon Mar 30, 2009 7:26 am

Fatal error: Call to undefined function mysql_connect()

Post by haughtycool »

I created a php file as following:

Code: Select all

<?php
$link = mysql_connect('localhost', 'admin', '123456');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>
When I call this file by browser, it shows:

Connected successfully

However when I use the php command line:

Code: Select all

/usr/local/bin/php -f /var/www/tmp/test.php

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:

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_r

Could anybody help me solve this problem. Thanks for any advance.
Post Reply