clonetrooper9494 Posted February 29, 2008 Share Posted February 29, 2008 I must have bad luck when it comes to PHP... I have a counter page that says the amount of people that have visited it that day, and total. but the way I am doing it, it never resets the today colum in my SQL DB... take a look and see if you can find any problems: <?phpsetcookie("counter",":-)",time()+3600*24*30*12*99*99,NULL,'.clone-drone.net');?><html><head><title>You were tricked</title></head><body bgcolor="#000000"><center><br><br><br><br><br><br><br><br><br><font color="#FFFFFF"><h3><?php$con = mysql_connect('localhost',***********,'***********');mysql_select_db("clonedro_email", $con);$a = mysql_query("SELECT * FROM Counter");$b = mysql_fetch_array($a);$d = date('G');if(!isset($_COOKIE['counter'])){ $n = mysql_query("UPDATE Counter SET number = number + 1"); $y = mysql_query("UPDATE Counter SET today = today + 1"); if($d < $b['hour']) { $x = mysql_query("UPDATE Counter SET today = 0"); $n = mysql_query("UPDATE Counter SET hour = $d"); }}echo $b['number']." people have been tricked to visit this page,<br>"echo $b['today']." people have been tricked today.";mysql_close($con);?></h3><br>Pass it on, tell your friends about it:<br>http://clone-drone.net/huh.phtml<br><br><br><br><br>Started Feb. 25, 2008</body></html> I have already tried deleting the cookie then revisiting the page, but nothing works! Link to comment Share on other sites More sharing options...
Jesdisciple Posted February 29, 2008 Share Posted February 29, 2008 I have a counter page that says the amount of people that have visited it that day, and total. but the way I am doing it, it never resets the today colum in my SQL DB... take a look and see if you can find any problems: if($d < $b['hour']) { $x = mysql_query("UPDATE Counter SET today = 0"); $n = mysql_query("UPDATE Counter SET hour = $d"); } I'm guessing this is the reset that doesn't happen, and I think I know why. You try to test the "military" hour for being less than $b['hour']. But $b is mysql_fetch_array($a), and $a contains your entire table, rather than the row that mysql_fetch_array() expects: $a = mysql_query("SELECT * FROM Counter"); I suspect that $b is either FALSE or NULL, which should make it 0 in a numerical comparison - which would explain why it can't be greater than date('G'). Link to comment Share on other sites More sharing options...
clonetrooper9494 Posted March 4, 2008 Author Share Posted March 4, 2008 ok! thanks for your help, it works now! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.