Re: Command Line Error

From: Date: Mon, 28 Mar 2005 16:00:25 +0000
Subject: Re: Command Line Error
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-39052@lists.php.net to get a copy of this message
Ron Piggott wrote:
I wrote a really simple 11 or 12 line PHP script to remove old entries from a web card application I made: <? $todays_date=DATE("Y-m-d"); [snip]
Take a look at this line: $todays_date=DATE("Y-m-d"); When it is ran from the command line this line causes the script to give these error messages: /home/actsmin/actsministries-www/webcards/administration/daily_maintenance.p hp3: line 3: syntax error near unexpected token `DATE("' /home/actsmin/actsministries-www/webcards/administration/daily_maintenance.p hp3: line 3: `$todays_date = DATE("Y-m-d");' Any idea why the command line can't deal with but the http:// version works just fine?
I'm guessing you're not running this through php, you've just made it executable? You need to either give it some #! magic (e.g. #!/bin/php) - or - more clearly, call php from cron and pass it this script. (In either case, <?php is better form than just <?. 00 8-19/2 * * mon-fri /usr/bin/php /foo/backup_script.php [if you aren't suppressing output properly, you can also do this] 00 8-19/2 * * mon-fri /usr/bin/php /foo/backup_script.php > /dev/null [though it's better to suppress output properly, so you can get any error messages/etc.] cheers, -- - Martin Norland, Sys Admin / Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital.

« previous php.db (#39052) next »