I'm using PHP version 5.1.6 and mysql. In my case i tried to run php in commnad line interface, i have no problem to 'echo' simple statement such as "Hello My World".
i put this line in my hello.php
#!/usr/bin/php
<?php
echo "Hello My World\n";
?>
and then run this command:
[root@anas]# php hello.php
Hello My World
[root@anas]#
But, when i tried to connect to mysql, i added these lines:
#!/usr/bin/php
<?php
echo "Hello My World\n";
$conn=mysql_connect('localhost','root','password');
if(!@$conn)
{
echo "Connection Refused!";
}
else
echo "Connection Accepted";
mysql_close($conn);
?>
i ran the command:
[root@anas]# php hello.php
Hello My World
PHP Fatal error: Call to undefined function mysql_connect() in /home/anaz/phpcli/truncate.php on line 4
[root@anas]#
I try to add run this file in the browser using apache webserver. The peocess was success. I got that error only in PHP CLI.
Can anyone help me to identify the problem and make the solution.