Hello,
I have a virtual pet website that has a soup kitchen which should only open at certain times during the day!
However, I want to be able to add more timings to the kitchen opening hours but for some reason the script doesnt execute the IF statement and therefore doesnt open at the times listed in the script. I have tried all sorts and cant seem to work it out! Im not sure if it is the coding or if its something to do with my server clock or my community PHP clock coding. :O(
Upon visiting during the opening hours (the IF statement), the soup kitchen is always closed and goes to the else statement.
Any obvious errors that I have over looked? I have put the piece of code and then have put the page code below.
Any help is much appreciated!
Justin
if ((($hour >= 01) AND ($hour <= 08)) OR (($hour >= 11) AND ($hour <= 13)) OR (($hour >= 18) AND ($hour <= 19)) AND (!$findCheck[id]))
{
print "<p align=center><center><a href=free_food.php?act=feedme&game=$game>Get your Free Meal!</a></p>";
}
else
{
print "<p align=center><b>Sorry, we're closed now, please come back during serving hours.</b></p>";
}
}
PAGE CODE:
<?php
/*
Free Food (free_food.php)
*/
$page_title = "Free Food";
$rank_check = 1;
include "header.inc.php";
print "$openHTML<br>";
// Start Check
$checking = "freefood";
$limit1 = 7200;
$limit = $timestamp - $limit1;
$findCheck = fetch("SELECT * FROM checking2 WHERE userid = '$userid' AND check_what = '$checking' AND timestamp > '$limit'");
// End Check
if ($act == "feedme")
{
if ($findCheck[id])
{
die("<p><center>You can only get free food ONCE per serving time. <a href=$base_url/free_food.php?game=$game>Back</a></p>$closeHTML");
}
$randHunger = rand(1,4);
mysql_query("UPDATE members2 SET hunger_level = hunger_level + $randHunger WHERE username = '$username' AND game = '$game'");
mysql_query("UPDATE user_pets2 SET hunger = hunger + $randHunger WHERE owner = '$userid' AND game = '$game'");
mysql_query("UPDATE members2 SET hunger_level = 10 WHERE username = '$username' AND game = '$game' AND hunger_level > '10'");
mysql_query("UPDATE user_pets2 SET hunger = 10 WHERE owner = '$userid' AND game = '$game' AND hunger > '10'");
if ($randHunger == "1") { $pageTitle = "Slim Pickings"; }
if ($randHunger == "2") { $pageTitle = "Satisfying Meal"; }
if ($randHunger == "3") { $pageTitle = "3 Course Meal"; }
if ($randHunger == "4")
{
$pageTitle = "Feasting!";
mysql_query("UPDATE members2 SET hunger_level = 10 WHERE username = '$username' AND game = '$game'");
mysql_query("UPDATE user_pets2 SET hunger = 10 WHERE owner = '$userid' AND game = '$game'");
}
mysql_query("DELETE FROM checking2 WHERE userid = '$userid' AND check_what = '$checking'");
mysql_query("INSERT INTO checking2 (userid,check_what,timestamp,game) VALUES ('$userid','$checking','$timestamp','$game')");
$findPage = fetch("SELECT * FROM game_pages WHERE page_title = '$pageTitle' AND game = '$game'");
if (!$findPage[id])
{
if ($randHunger == "1") { print "<p><center>Sorry, but hardly anyone in the community has been donating, we only have left overs from yesterdays meal.</p>"; }
if ($randHunger == "2") { print "<p><center>Here you go, the main course and an ice cold drink!</p>"; }
if ($randHunger == "3") { print "<p><center>Quite a few people in the community have been donating! You get a full three course meal!!</p>"; }
if ($randHunger == "4") { print "<p><center>WOW! A big food drive has just been completed, you FEAST on food and you and your pets are all full!</p>"; }
}
else
{
print "$findPage[page_info]";
}
}
if ($act != "feedme")
{
$findPage = fetch("SELECT * FROM game_pages WHERE page_title = '$page_title' AND game = '$game'");
if (!$findPage[id])
{
print "<p><center>Welcome to the Soup Kitcen, we serve food to the needy every day. So put your pride aside and please take some food :)</p>
<p>Business hours:<Br>
7 AM to 8 AM GMT <br>
11 AM to 1 PM GMT and<Br>
6 PM to 7 PM GMT </p>
<p><br> These hours do sometimes change depending on our volunteers so keep coming back if we dont happen to be open... Thank you! :O)
";
}
else
{
print "$findPage[page_info]";
}
if ((($hour >= 01) AND ($hour <= 08)) OR (($hour >= 11) AND ($hour <= 13)) OR (($hour >= 18) AND ($hour <= 19)) AND (!$findCheck[id]))
{
print "<p align=center><center><a href=free_food.php?act=feedme&game=$game>Get your Free Meal!</a></p>";
}
else
{
print "<p align=center><b>Sorry, we're closed now, please come back during serving hours.</b></p>";
}
}
print "$closeHTML";
?>