Cron job problem, not working at all

the cron job is listed as this…

/5 0 * * * php -f /home/a5*****/public_html/pancron.php

pancron.php

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”
http://www.w3.org/TR/html4/loose.dtd”>
<html>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=iso-8859-1”>
<title>Untitled Document</title>
</head>

<body>
<?php
$url =‘http://www.ctlinx.com/org/panprix/admin/php/pancron.php’;
header('Location: '.$url);
?>
</body>
</html>

and that points to…

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”
http://www.w3.org/TR/html4/loose.dtd”>
<html>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=iso-8859-1”>
<title>Untitled Document</title>
</head>
<body>
<?
$user=“a5818989_pan”;
$password=Deleted by moderator;
$database=“a5818989_pan”;
mysql_connect(“mysql7.000webhost.com”,$user,$password);
@mysql_select_db($database) or die( “Unable to select database”);

	$query="SELECT * FROM cron";

	$result=mysql_query($query);
	$num=mysql_num_rows($result);

	$counter = mysql_result($result,$i,"counter");
	$counter = $counter +1;

	$query2 = "UPDATE cron SET counter = '$counter'";
	mysql_query($query2);
	mysql_close();
	
	echo "$counter";

?>
</body>
</html>

I’m fairly new to cron jobs. I have tried it several ways including…

every 15 minutes, I used several ways to point to the script I need run (due to the fact that I read the script cannot be on the same page the cron job points to, I did have it set there too and it didn’t work.

I know the script works as when I go to that page the counter goes up. I plan to create a racing game and will do so as soon as I can get the cron job to work properly, I will also be paying for the better hosting service but I want to get the game at least 90% done first.

What am I doing wrong here?

and thank you in advance for any help you can provide.

Hello,

I do not understand why you are using two files and I think you do not have very clear how you must use the cron.

Have you tried to run your second script directly to see if it work well?
I think your second “script file” contains errors.

What do you want to get when you run the cron?

I tried it with 1 file, still didn’t work
I just want the counter to go up by one for now, once its working I can add what I need to it later
the second script does indeed work try it for yourself http://www.ctlinx.com/org/panprix/admin/php/pancron.php
I also did mention that I am new to cron so yeah I’m sure you’re right in that I don’t know it very well

[1 minute later]

oh and thank you for deleting the password, I didn’t realize it was in there… I will change it now anyway to be sure

I do not know much about cron, but I think the cron tool is used for internal processes within the server (back up the database, cleaning temporary files, etc), but I think it is wrong to use it to generate an HTML page, because the cron can not display a page a visitor/user of your website.

I think you should try with schemes such as “javascript” or “labels in head” to reload the website from time to time.

I’ll move this thread to the “Web programming”. Surely there are more users that can help to resolve your issue.

ok thank you, Though I am not intending to generate a page using cron, It is ok if it is never seen by anyone as long as the counter goes up and is saved to SQL, eventually I plan to use it only to make a timer count down so that I can start races automatically without anyone having to log on and do it manually. I looked into javascript but it just seemed overly complicated and figured it would be a lot easier just to use a cron job

If I’m not mistaken, the header function for php cannot be called after any html has been written. For that reason, your first page will NOT link to the second.