Jump to content

Recommended Posts

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

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'); ?>"

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);
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.