I have set the php file in cron job on the parallel plesk 10.4.4 server.In notification email it is showing the errors.

      syntax error near unexpected token `<' 
     syntax error near unexpected token `newline'
     /newsletter_auto.php: line 2: `<html>'

the code of the newsletter_auto.php file is below

        <title>Market Trend Newsletter</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
var abc=encodeURIComponent($("#newsletter").html());
    function checkForNULLString($str)
        if($str == "" || $str == " " || $str == "  " || $str == "   " || $str == "    " || $str == "     " || $str == "       " || $str == null)
            return false;
            return true;

    function cleanForDatabase($str)
        $str =  preg_replace('/[^a-zA-Z0-9\s-_#@.,]/', '', $str);
        $str = mysql_real_escape_string($str);

        return $str;

    function runSQLQuery($query,$mysqlConnect)
        $result = mysql_query($query,$mysqlConnect);

        if(mysql_errno($mysqlConnect) != 0){
            echo "\n !<u>!ERROR:</u>mysqlConnect:".$mysqlConnect." <br/>query:".$query."<br/> Query.result:" . mysql_errno($mysqlConnect) . ": " . mysql_error($mysqlConnect) . "\n";

            //Log the Query Error
            $result = mysql_query($query,$mysqlConnect); exit();



    function insertIconAdminLink($link,$name,$type,$text=NULL,$target="_self")
        //print"<a href=\"".$link."\" onmouseout=\"Javascript:roll_over_switch('".$name."',false);\" onmouseover=\"Javascript:roll_over_switch('".$name."',true);\"><img name=\"".$name."\" id=\"".$name."\" border=\"0\" src=\"/images/".$type.".gif\" />".$text."</a>";

        print" <a class=\"iconLinkText\" href=\"".$link."\" target=\"".$target."\"><img name=\"".$name."\" id=\"".$name."\" border=\"0\" src=\"/images/".$type.".gif\" width=\"24\" height=\"24\" />".$text."</a> ";

    <div id="newsletter"> <p>Stocks traded <?php echo $stock_direction; ?> today with the <?php echo $stock_index; ?> closing at <?php echo $stock_index_close; ?>, <?php echo $stock_direction; ?> <?php echo $stock_index_difference; ?> or <?php echo $stock_index_percentage_difference; ?> from the previous close. The number of NYSE advances were <?php echo $nyse_advances; ?>, the number of decliners was </div>

Please let me know how can I resolve this?

  • Please show us (the beginning at least of ) the script that is causing this problem by editing your question then flag to have the question reopened. – Iain May 25 '12 at 21:46
  • in script is worrking on the browser when I set it as cron as it is giving these errors in the notificaton email.you can see the code – Rohan Kapoor May 25 '12 at 21:55
  • 1
    what is your cron entry for it ? – Iain May 25 '12 at 21:58
  • I have give the path from the root. /var/www/sitename/httpdocs/beta1/newsletter_auto.php – Rohan Kapoor May 25 '12 at 22:01
  • I searched about it according to that it is reading the < and > sign as the place holder – Rohan Kapoor May 25 '12 at 22:26

That is the error you would expect if you execute a php template file e.g. test.php under the bash script interpretor, for example if you create a basic php script file;

$ echo -e "<html>\n</body><?php echo 'test'?></body></html>" > ~/test.php
$ cat test.php 
</body><?php echo 'test'?></body></html>

and make it executable, and then try and execute it directly...

$ chmod +x test.php 
$ ./test.php 
./test.php: line 1: syntax error near unexpected token `newline'
./test.php: line 1: `<html>'

This is because the shell is trying to run the script under the default script interpreter, i.e. bash, its the equivalent of this;

$ bash test.php 
test.php: line 1: syntax error near unexpected token `newline'
test.php: line 1: `<html>'

at the very least, something like this would at least run the php script under the php;

$ /usr/bin/php test.php

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.