mattal999 Posted September 29, 2007 Share Posted September 29, 2007 I have this script which checks the date of the players last race: <?php include "connect.php"; $date = date("Y-m-d"); $player=$_SESSION['username']; $playerstats1="SELECT * from dragusers WHERE username='$player'"; $playerstats2=mysql_query($playerstats1) or die ("Could not find player"); while($playerstats3=mysql_fetch_array($playerstats2)) { $MySqlDate = $playerstats3[lastrace]; if($MySqlDate == '0000-00-00') { header("location:gorace.php"); } else { $date_array = explode("-",$MySqlDate); $var_year = $date_array[0]; $var_month = $date_array[1]; $var_day = $date_array[2]; $donewtime = date("d-m-Y", mktime(0, 0, 0, $var_month, $var_day, $var_year)); if(strtotime($playerstats3[lastrace]) > time()) { print "You can race again tommorow"; } if(strtotime($playerstats3[lastrace]) < time()) { $updateplayerstats="Update rpgusers set lastrace='0' where username='$playerstats3[username]'"; mysql_query($updateplayerstats) or die("<body bgcolor='3d3d3d'><font color='ffffff' size='1' face='verdana'>Could not update player stats"); print "You can now have 3 More Races"; } if(strtotime($playerstats3[lastrace]) == time()) { $updateplayerstats="Update rpgusers set lastrace='0' where username='$playerstats3[username]'"; mysql_query($updateplayerstats) or die("<body bgcolor='3d3d3d'><font color='ffffff' size='1' face='verdana'>Could not update player stats"); print "You can now have 3 More Races"; } } } ?> and it it formatted 0000-00-00. When i run this i get a blank white page no matter what... Help? Quote Link to comment https://forums.phpfreaks.com/topic/71157-solved-error-in-date-check/ Share on other sites More sharing options...
btherl Posted September 29, 2007 Share Posted September 29, 2007 Try adding some print statements throughout your code. These can show you what the values of variables are. They can also tell you if your script dies at some point. Also try adding this at the start of your script: ini_set('display_errors', 1); Quote Link to comment https://forums.phpfreaks.com/topic/71157-solved-error-in-date-check/#findComment-357885 Share on other sites More sharing options...
Daleeburg Posted September 29, 2007 Share Posted September 29, 2007 First off, when i am looking for errors i find it very helpful if i format my code <?php include "connect.php"; $date = date("Y-m-d"); $player=$_SESSION['username']; $playerstats1="SELECT * from dragusers WHERE username='$player'"; $playerstats2=mysql_query($playerstats1) or die ("Could not find player"); while($playerstats3=mysql_fetch_array($playerstats2)){ $MySqlDate = $playerstats3[lastrace]; if($MySqlDate == '0000-00-00') { header("location:gorace.php"); } else { $date_array = explode("-",$MySqlDate); $var_year = $date_array[0]; $var_month = $date_array[1]; $var_day = $date_array[2]; $donewtime = date("d-m-Y", mktime(0, 0, 0, $var_month, $var_day, $var_year)); if(strtotime($playerstats3[lastrace]) > time()) { print "You can race again tommorow"; } if(strtotime($playerstats3[lastrace]) < time()) { $updateplayerstats="Update rpgusers set lastrace='0' where username='$playerstats3[username]'"; mysql_query($updateplayerstats) or die("<body bgcolor='3d3d3d'><font color='ffffff' size='1' face='verdana'>Could not update player stats"); print "You can now have 3 More Races"; } if(strtotime($playerstats3[lastrace]) == time()) { $updateplayerstats="Update rpgusers set lastrace='0' where username='$playerstats3[username]'"; mysql_query($updateplayerstats) or die("<body bgcolor='3d3d3d'><font color='ffffff' size='1' face='verdana'>Could not update player stats"); print "You can now have 3 More Races"; } } } ?> and if I had to guess, you are making an infinite loop with the while statement. also, i dont know a ton about arrays, but can you use words in them or does it have to be numbers ~d Quote Link to comment https://forums.phpfreaks.com/topic/71157-solved-error-in-date-check/#findComment-357943 Share on other sites More sharing options...
mattal999 Posted September 29, 2007 Author Share Posted September 29, 2007 you were right, i was creating a infinite loop with while(); cheers Quote Link to comment https://forums.phpfreaks.com/topic/71157-solved-error-in-date-check/#findComment-357991 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.