[PHP-DB] Command Line Error
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); $username=user; $password=password; $database=database; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( Unable to select database); $query = DELETE FROM `webcardtable` WHERE `date_to_be_deleted` LIKE '$todays_date'; mysql_query($query); mysql_close(); ? When this is run from the web it works fine. I wanted it on a CRON then the expired entries are removed automatically. 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? Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Command Line Error
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. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Command Line Error
Martin Norland wrote: 00 8-19/2 * * mon-fri /usr/bin/php /foo/backup_script.php I should have mentioned this - this runs twice an hour Monday through Friday, between the hours of 8am and 7pm. You would more likely prefer 05 1* * * your_command which would run at 1:05am every day. use 'crontab -e' to edit your own crontab. 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. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Command Line Error
I didn't realize I was required to do this. Would you put this line where it belongs? I am not sure what to do with the ? and ? and if these are needed for the script to run from the command line. Ron #!/path to php cli binary ? $todays_date=DATE(Y-m-d); $username=user; $password=password; $database=database; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( Unable to select database); $query = DELETE FROM `webcardtable` WHERE `date_to_be_deleted` LIKE '$todays_date'; mysql_query($query); mysql_close(); ? - Original Message - From: [EMAIL PROTECTED] To: Ron Piggott [EMAIL PROTECTED] Sent: Monday, March 28, 2005 11:02 AM Subject: Re: [PHP-DB] Command Line Error are you putting: #!/path to php cli binary at the top of your page? if not, it will be interpreted as a shell (bash/csh) script. -- Original Message -- From: Ron Piggott [EMAIL PROTECTED] To: PHP DB php-db@lists.php.net Date: Monday, March 28, 2005 09:54:00 AM -0500 Subject: [PHP-DB] Command Line Error 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); $username=user; $password=password; $database=database; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( Unable to select database); $query = DELETE FROM `webcardtable` WHERE `date_to_be_deleted` LIKE '$todays_date'; mysql_query($query); mysql_close(); ? When this is run from the web it works fine. I wanted it on a CRON then the expired entries are removed automatically. 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_main tenance.p hp3: line 3: syntax error near unexpected token `DATE(' /home/actsmin/actsministries-www/webcards/administration/daily_main tenance.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? Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- End Original Message -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Command Line Error
Goes right where you have it #!/path to php cli binary ?php ...rest of your script ? Bastien From: Ron Piggott [EMAIL PROTECTED] To: [EMAIL PROTECTED] CC: PHP DB php-db@lists.php.net Subject: Re: [PHP-DB] Command Line Error Date: Mon, 28 Mar 2005 12:35:09 -0500 I didn't realize I was required to do this. Would you put this line where it belongs? I am not sure what to do with the ? and ? and if these are needed for the script to run from the command line. Ron #!/path to php cli binary ? $todays_date=DATE(Y-m-d); $username=user; $password=password; $database=database; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( Unable to select database); $query = DELETE FROM `webcardtable` WHERE `date_to_be_deleted` LIKE '$todays_date'; mysql_query($query); mysql_close(); ? - Original Message - From: [EMAIL PROTECTED] To: Ron Piggott [EMAIL PROTECTED] Sent: Monday, March 28, 2005 11:02 AM Subject: Re: [PHP-DB] Command Line Error are you putting: #!/path to php cli binary at the top of your page? if not, it will be interpreted as a shell (bash/csh) script. -- Original Message -- From: Ron Piggott [EMAIL PROTECTED] To: PHP DB php-db@lists.php.net Date: Monday, March 28, 2005 09:54:00 AM -0500 Subject: [PHP-DB] Command Line Error 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); $username=user; $password=password; $database=database; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( Unable to select database); $query = DELETE FROM `webcardtable` WHERE `date_to_be_deleted` LIKE '$todays_date'; mysql_query($query); mysql_close(); ? When this is run from the web it works fine. I wanted it on a CRON then the expired entries are removed automatically. 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_main tenance.p hp3: line 3: syntax error near unexpected token `DATE(' /home/actsmin/actsministries-www/webcards/administration/daily_main tenance.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? Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- End Original Message -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php