mysql_connect working in browser but not in terminal

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jayarajmohan
Forum Newbie
Posts: 16
Joined: Fri Aug 29, 2008 12:06 am

mysql_connect working in browser but not in terminal

Post by jayarajmohan »

Hi,

I am using PHP Version 5.2.5 in my server. when i run this code in browser its working fine but when i tried to run this from terminal its shows error.

$dbhost='localhost';
$dbusername='username';
$dbuserpass='paswordl';
$dbname='dbname';

// connect to the mysql database server.
$link_id = mysql_connect($dbhost, $dbusername, $dbuserpass);

Error shown in terminal when do this : php /opt/lampp/htdocs/test.php

X-Powered-By: PHP/4.2.2
Content-type: text/html

<br />
<b>Fatal error</b>: Call to undefined function: mysql_connect() in <b>/opt/lampp/htdocs/test.php</b> on line <b>9</b><br />

Please give your idea to overcome this,,
filippo.toso
Forum Commoner
Posts: 30
Joined: Thu Aug 07, 2008 7:18 am
Location: Italy
Contact:

Re: mysql_connect working in browser but not in terminal

Post by filippo.toso »

You should be able to avoid it using the -c parameter to specify the right php.ini file.
Post Reply