So I have a cronjob which executes a PHP script like so:
0 0 * * * /usr/local/bin/php -f /home/mysite/mysite.com/cronjobs/renewal_email.php
If I issue the same command from the command line it runs without error and running with the l flag shows no syntax errors. However cron emails the following:
Parse error: syntax error, unexpected T_OBJECT_OPERATOR
The line in question is
$courses[$t->CourseNumber] = $t->course()->CourseName;
Does this limited amount of info raise any red flags? Anyone see why this should happen under cron but not from the command line?
TIA!
JG
// Edit to add DreamHost support response. Script is working with this change.
The default version of PHP on the server is PHP4. This is because the server uses the PATH settings rather than the Apache to specify which version is run. The path for PHP4 /usr/local/bin/php comes before the PHP5 path /usr/local/php5/bin/php so it always runs first when you type php from the shell.
To run PHP5 from the shell you need to specify the entire path:
/usr/local/php5/bin/php --version
The cron user will not use your .bash_profile path so you would need to specify the full path to PHP5 in each cron job.