twiztedbluz Posted February 7, 2007 Share Posted February 7, 2007 This is for a dog sim that I own. My script was working fine up until a week ago, and it went haywire, and I have no idea in heck is wrong with it. I've checked everything that I can think of, not sure why. But this script is suppose to run shows (Created by players) automatically on the day they want, But now, they are all piling up. <? include 'header.php'; //=================If they press 'Search' if ($_POST['find']){ $event = $_POST['event']; $dog = $_POST['dog']; $days = $_POST['run_date']; $rundate = date ('Y/m/d', strtotime ("$date + $days days")); $sql3 = mysql_query("SELECT * FROM dog WHERE dogID='$dog'"); $row3 = mysql_fetch_assoc($sql3); //figure out dog's level $var = $row3['conformation'] + $row3['agility'] + $row3['speed'] + $row3['endurance'] + $row3['intelligence'] + $row3['obedience']; if ($var > 0 && $var <= 90){ $dog_level = 'Level 1'; } else if ($var >= 91 && $var <= 190){ $dog_level = 'Level 2'; } else if ($var >= 191 && $var <= 290){ $dog_level = 'Level 3'; } else if ($var >= 291 && $var <= 390){ $dog_level = 'Level 4'; } else if ($var >= 391 && $var <= 490){ $dog_level = 'Level 5'; } else if ($var >= 491){ $dog_level = 'Level 6'; } mysql_query("UPDATE dog SET level='$dog_level' WHERE dogID='$dog'"); $sql1 = mysql_query("SELECT showID, showname, event, level, prize, entryfee FROM shows WHERE event='$event' AND level='$dog_level' AND rundate ='$rundate'"); $num = mysql_num_rows($sql1); if ($num == 0){ print "<table class='echo' width='40%'><td class='echo' align='center'><b>No shows matched for $event - $dog_level</b></td></table><p>"; } else { print<<<HERE <h3>Search Results for $event - $dog_level:</h3> <table class='main' width="90%" align="center" valign="center"> <th>Name</th> <th>Event</th> <th>level</th> <th>Entry Fee</th> <th>Prize</th> <th>Enter?</th> <tr class='main' align="center"> HERE; while ($row1 = mysql_fetch_assoc($sql1)){ echo "<td><a href='viewshowentries.php?showID=$row1[showID]'>$row1[showname]</a></td>"; echo "<td>$row1[event]</td>"; echo "<td>$row1[level]</td>"; echo "<td>$$row1[entryfee]</td>"; echo "<td>$$row1[prize]</td>"; echo "<td><a href='shows.php?showID=$row1[showID]&dogID=$dog&level=$dog_level'>Enter</a></td><tr class='main' align='center'>"; } include 'footer.php'; exit; } } /**********If they press 'Enter'**************/ $showID = $_GET['showID']; if ($showID){ //Are they the dogs owner? $sql8 = mysql_query("SELECT ownerID, shows_entered, age, level FROM dog WHERE dogID='$_GET[dogID]'"); $row8 = mysql_fetch_assoc($sql8); $sql20 = mysql_query("SELECT upgrade, money FROM players WHERE playerID='$sid'"); $player = mysql_fetch_assoc($sql20); $sql21 = mysql_query("SELECT showID FROM shows WHERE showID=$_GET[showID]"); $shownum = mysql_num_rows($sql21); if ($player['upgrade'] == 'yes'){ $maxshows = 150; } else { $maxshows = 75; } $sql21 = mysql_query("SELECT dogID FROM show_entries WHERE dogID='$_GET[dogID]'"); $numshows = mysql_num_rows($sql21); if ($numshows >= $maxshows){ print "<table class='echo'><td class='echo'><b>This dog is entered in their max amount of shows!</b></td></table>"; exit; } if ($shownum <= 0){ print "<table class='echo'><td class='echo'><b>This show does not exist!</b></td></table>"; exit; } if ($row8['ownerID'] != $sid){ print "<table class='echo'><td class='echo'><b>This is not your dog!</b></td></table>"; exit; } if ($_GET['level'] != $row8['level']){ echo 'wrong level!'; exit; } if ($row8['age'] < '2'){ print "<table class='echo'><td class='echo'><b>This dog is too young to enter shows!</b></td></table>"; exit; } $show_check = mysql_query("SELECT showID, dogID FROM show_entries WHERE showID='$showID' AND dogID='$_GET[dogID]'"); $num_check = mysql_num_rows($show_check); if ($num_check > 0){ print "<table class='echo'><td class='echo'><b>This dog has already been entered in this show!</b></td></table>"; exit; } $showsql = mysql_query("SELECT rundate, creatorID, entryfee FROM shows WHERE showID='$showID'"); $show = mysql_fetch_assoc($showsql); if ($player['money'] < $show['entryfee']){ print "<table class='echo'><td class='echo'><b>You don't have enough money to enter this show!</b></td></table>"; exit; } print "<table class='echo'><td class='echo'><b>Successfully entered show!</b></td></table><p>"; //check how many points are added to their 'score' $sql3 = mysql_query("SELECT * FROM dog WHERE dogID='$dogID'"); $row3 = mysql_fetch_assoc($sql3); if ($row3['happiness'] >= 90){ $s1 = 20; } else if ($row3['happiness'] >= 89 && $row3['hunger'] <= 80){ $s1 = 18; } else if ($row3['happiness'] >= 79 && $row3['hunger'] <= 70){ $s1 = 16; } else if ($row3['happiness'] >= 69 && $row3['hunger'] <= 60){ $s1 = 14; } else if ($row3['happiness'] >= 59 && $row3['hunger'] <= 50){ $s1 = 12; } else if ($row3['happiness'] >= 49 && $row3['hunger'] <= 40){ $s1 = 10; } else if ($row3['happiness'] >= 39 && $row3['hunger'] <= 30){ $s1 = 8; } else if ($row3['happiness'] >= 29 && $row3['hunger'] <= 20){ $s1 = 6; } else if ($row3['happiness'] >= 19 && $row3['hunger'] <= 10){ $s1 = 4; } else { $s2 = 2; } if ($row3['hunger'] >= 90){ $s2 = 20; } else if ($row3['hunger'] >= 89 && $row3['hunger'] <= 80){ $s2 = 18; } else if ($row3['hunger'] >= 79 && $row3['hunger'] <= 70){ $s2 = 16; } else if ($row3['hunger'] >= 69 && $row3['hunger'] <= 60){ $s2 = 14; } else if ($row3['hunger'] >= 59 && $row3['hunger'] <= 50){ $s2 = 12; } else if ($row3['hunger'] >= 49 && $row3['hunger'] <= 40){ $s2 = 10; } else if ($row3['hunger'] >= 39 && $row3['hunger'] <= 30){ $s2 = 8; } else if ($row3['hunger'] >= 29 && $row3['hunger'] <= 20){ $s2 = 6; } else if ($row3['hunger'] >= 19 && $row3['hunger'] <= 10){ $s2 = 4; } else { $s2 = 2; } if ($row3['vaccinated'] == yes){ $s3 = 5; } else if ($row3['vaccinated'] == no){ $s3 = 0; } $randstat = rand(1,6); $ss = $s1 + $s2 + $s3 + $randstat; mysql_query("insert into show_entries(showID, entererID, dogID, rundate, score, conformation, agility, speed, endurance, intelligence, obedience)values('$showID', '$sid', '$dogID', '$show[rundate]', '$ss', '$row3[conformation]', '$row3[agility]', '$row3[speed]', '$row3[endurance]', '$row3[intelligence]', '$row3[obedience]')")or die(mysql_error()); mysql_query("UPDATE dog SET shows_entered=shows_entered+1 WHERE dogID='$dogID'"); mysql_query("UPDATE players SET money = money-$show[entryfee] WHERE playerID='$sid'"); mysql_query("UPDATE players SET money = money+$show[entryfee] WHERE playerID='$show[creatorID]'"); $sql5 = mysql_query("SELECT * FROM show_entries WHERE showID='$showID'"); print<<<HERE <h3>Entries for show #$showID</h3> <table class='main' width="60%" align="center" valign="center"> <th>Dog's Name</th> <th>Owner</th> <tr class='main' align="center"> HERE; while ($row5 = mysql_fetch_assoc($sql5)){ $sql9 = mysql_query("SELECT name FROM dog WHERE dogID='$row5[dogID]'"); $row9 = mysql_fetch_assoc($sql9); $sql10 = mysql_query("SELECT username FROM players WHERE playerID='$row5[entererID]'"); $row10 = mysql_fetch_assoc($sql10); echo "<td>$row9[name]</td>"; echo "<td><a href='viewprofile.php?profileid=$row5[entererID]'>$row10[username]</a></td><tr class='main' align='center'>"; } include 'footer.php'; exit; } /**********Search Form**********/ print<<<HERE <table class='main' width='35%'> <td class='main' align='center'> <h3>Search Shows</h3> <form action="shows.php?action=search" method="post"> Which dog would you like to enter?<br> <select name="dog"> HERE; $sql20 = mysql_query("SELECT ownerID, dogID, name FROM dog WHERE ownerID='$sid' AND age >= '2' AND age <= '12'"); while ($row20 = mysql_fetch_assoc($sql20)){ echo "<option value='$row20[dogID]'>$row20[name]</option>"; } print<<<HERE </select><p> Event Type:<br> <select name="event"> <option>Conformation</option> <option>Sporting</option> <option>Herding</option> <option>Agility</option> <option>Working</option> <option>Hunting</option> <option>Obedience</option> <option>Racing</option> <option>Show</option> <option>Flyball</option> </select><p> Run in: <select name="run_date"> <option>0</option> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> <option>6</option> <option>7</option> </select> day(s)<p> <input type="submit" name="find" value="Search"> </td></table> </form><p><p> <a href="createshows.php">Create Shows</a><p><p><p> <h4>Show Chart (Ignore until I tell you not to, which will be a day or two from now)</h4> This chart will tell you which 3 stats will help your dog do best in each show type. So make sure you enter the shows your dog is most likely to win =D<p> <table class='main' width="100%" valign='center' align='center'> <tr class='main'> <th>Conformation</th> <th>Sporting</th> <th>Herding</th> <th>Agility</th> <th>Working</th> <th>Hunting</th> <th>Obedience</th> <th>Racing</th> <th>Show</th> <th>Flyball</th> <tr class='main' align='center'> <td>Conformation</td> <td>Agility</td> <td>Speed</td> <td>Agility</td> <td>Agility</td> <td>Endurance</td> <td>Conformation</td> <td>Conformation</td> <td>Conformation</td> <td>Agility</td> <tr class='main' align='center'> <td>Intelligence</td> <td>Speed</td> <td>Intelligence</td> <td>Speed</td> <td>Endurance</td> <td>Intelligence</td> <td>Intelligence</td> <td>Speed</td> <td>Intelligence</td> <td>Speed</td> <tr class='main' align='center'> <td>Obedience</td> <td>Endurance</td> <td>Obedience</td> <td>Endurance</td> <td>Obedience</td> <td>Obedience</td> <td>Obedience</td> <td>Endurance</td> <td>Obedience</td> <td>Intelligence</td> </table> HERE; include 'footer.php'; ?> EDITED BY WILDTEEN88: Please use the code ( ) or PHP ( ) tags when posting code in posts. Thank you. Link to comment https://forums.phpfreaks.com/topic/37500-solved-script-not-running/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.