Voodoo Jai Posted July 11, 2008 Share Posted July 11, 2008 I have created a cronjob but when its executed I get this error msg: /hsphere/local/home/user/CRON-Job.php: line 1: syntax error near unexpected token `require_once('' /hsphere/local/home/user/CRON-Job.php: line 1: `<?php require_once('domain.com/MYConn/MY_conn.php'); ?>' the contents of the file are: <?php require_once('domain/MYConn/MY_conn.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_MY_conn, $MY_conn); $query_IPStoreDelete = "SELECT * FROM store"; $StoreDel = mysql_query($query_StoreDel, $MY_conn) or die(mysql_error()); $row_StoreDel = mysql_fetch_assoc($StoreDel); $totalRows_StoreDel = mysql_num_rows($StoreDel); $query = mysql_query("delete from store where to_days(now())-to_days(date) > 1"); mysql_query($query); //mysql_close(); mysql_free_result($StoreDel); ?> If there is an error in the paths I know I have just changed them to protect detailed data. Have I overlloked something or is the syntax different for cronjobs. Many thanks VoodooJai Quote Link to comment https://forums.phpfreaks.com/topic/114236-solved-error-msg-regarding-syntax-looks-fine-to-me/ Share on other sites More sharing options...
0siris Posted July 11, 2008 Share Posted July 11, 2008 I didn't think require_once needed brackets, but I could be wrong about that. Quote Link to comment https://forums.phpfreaks.com/topic/114236-solved-error-msg-regarding-syntax-looks-fine-to-me/#findComment-587407 Share on other sites More sharing options...
vikramjeet.singla Posted July 11, 2008 Share Posted July 11, 2008 try php command line path at the beginning of the cron file same as in perl.... for example: #!/web/cgi-bin/php Quote Link to comment https://forums.phpfreaks.com/topic/114236-solved-error-msg-regarding-syntax-looks-fine-to-me/#findComment-587408 Share on other sites More sharing options...
Voodoo Jai Posted July 11, 2008 Author Share Posted July 11, 2008 try php command line path at the beginning of the cron file same as in perl.... for example: #!/web/cgi-bin/php Do I just put the "#!/web/cgi-bin/php" instead of the "<?php require_once('lostmymenu.com/Connections/LostMyMenu_conn.php'); ?>" Quote Link to comment https://forums.phpfreaks.com/topic/114236-solved-error-msg-regarding-syntax-looks-fine-to-me/#findComment-587410 Share on other sites More sharing options...
vikramjeet.singla Posted July 11, 2008 Share Posted July 11, 2008 place this at the beginning of your "CRON-Job.php" but confirm path of php command line it may be different.... #!/web/cgi-bin/php <?php require_once('domain/MYConn/MY_conn.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_MY_conn, $MY_conn); $query_IPStoreDelete = "SELECT * FROM store"; $StoreDel = mysql_query($query_StoreDel, $MY_conn) or die(mysql_error()); $row_StoreDel = mysql_fetch_assoc($StoreDel); $totalRows_StoreDel = mysql_num_rows($StoreDel); $query = mysql_query("delete from store where to_days(now())-to_days(date) > 1"); mysql_query($query); //mysql_close(); mysql_free_result($StoreDel); ?> Quote Link to comment https://forums.phpfreaks.com/topic/114236-solved-error-msg-regarding-syntax-looks-fine-to-me/#findComment-587430 Share on other sites More sharing options...
Voodoo Jai Posted July 11, 2008 Author Share Posted July 11, 2008 the correct line was: #!/usr/local/bin/php Thank you all again for all your help Quote Link to comment https://forums.phpfreaks.com/topic/114236-solved-error-msg-regarding-syntax-looks-fine-to-me/#findComment-587446 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.