CAN'T connect to db when running PHP as Cron
| From: | Reuben D Budiardja | Date: | Wed, 18 Jul 2001 13:15:46 +0000 |
| Subject: | CAN'T connect to db when running PHP as Cron | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-58431@lists.php.net to get a copy of this message | ||
I post this yesterday, but no one responds. Please someone help. I wonder if
my problem is actually a bug in php or cron.
------------------------------------------
Hello,
I have a php script that connect to database and retrieve something, or do
something with the db.
I can run the script from the command line, it works just fine.
But when I run it as cron, it gives error cannot connect to the database.
Here is the script looks like:
<?
// script name: ora_test.php
$conn = ora_logon("username@db", "password");
$cur = ora_open($conn);
if (ora_parse($cur, "select something from table"))
{
ora_exec($cur);
while(ora_fetch($cur))
{
$something[] = ora_getcolumn($cur, 0);
}
print_r($something);
$msg = '';
for ($i=0; $i<count($something); $i++)
$msg .= $something[$i] ." ";
mail ("me@localhost", "test", $msg);
}
?>
Here is the crontab entry:
*/1 * * * * /usr/local/bin/php ora_test.php >> /tmp/cron_oralog
The error message from cron_oralog files is:
X-Powered-By: PHP/4.0.3pl1
Content-type: text/html
Warning: Oracle: Connection Failed: Error while trying to retrieve
text for error ORA-12154
in ora_test.php on line 3
Warning</b>: Supplied argument is not a valid Oracle-Connection resource
in <b>ora_test.php</b> on line <b>5</b>
<br>
<b>Warning</b>: Supplied argument is not a valid Oracle-Cursor resource in
<b>ora_test.php</b> on line <b>7</b><br>
Any help on this would be greatly appreciated.
Thanks.
Reuben D. Budiardja