Cron syntax error


I am getting this below error while running script through cron

line 1: syntax error near unexpected token `('
line 1: `<?php require_once('config.php');'

No error is shown if i run script through browser.

Dont know why it is showing error while running through cron ??


Try this:

`<?php require_once( "config.php" );'

// or this

"<?php require_once( 'config.php' );"

Please supply the before, offending and after lines.

If the file is PHP then you should not have a leading single quotation before <?php

Hi John

Quotes got copied from my email because cron was sending error at my email id

In the PHP file there are not quotes before <?php

Also i tried both below versions, but they didnt worked.

require_once( "config.php" );
require_once( 'config.php' );

Same error is coming


Try this:

require_once  "config.php" ;
require_once  'config.php' ;

If that does not work then maybe the file is corrupt so try copying and pasting the contents into a text editor and over-writing the old file. Hopefully it will be BOM free

require_once is not a function, it’s a statement

require_once "config.php";

lol well, at least Discourse is ninja thread safe

1 Like

In the good old days when using PHP 4

Even though it is a statement, braces were allowed/required?

 The require_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the require() statement, with the only difference being that if the code from a file has already been included, it will not be included again. See the documentation for require() for more information on how this statement works.

AFAIK there is no syntax difference between using the parentheses and not. Several places, actually, recommend you to not, because it isn’t a function. But I’ve never come across any functional difference (see what I did there :smiley: :smiley: ). I’d assume the best argument in favor of no-parenthesis is simply “type less” - that’s the reason I have tried to form the habit.

Maybe this is not an Error message but a Notice?

Yeah, could be… or maybe there’s something farther up the code we need to see?

Any chance the error is from inside the config.php file?


Here is my config file code.

Its working fine in browser without any error.

<?php $conn=mysql_connect("localhost","root","") or die(mysql_error());
$now = time(); 


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.