Cron Job [Resolved]
Posted: Sat Oct 12, 2013 10:37 am
Okay, for some reason my cronjob stopped working when I switched to mysqli. Anyone see the problem? I've looked and tampered with for an hour or so. It's supposed to update the rankings, but isn't. Makes it hard to fix when there is no visible error
cronjob
It is not working at all. Doesn't pull the players attack or defense and list it like it should

Here is my page that calls the information:


cronjob
Code: Select all
<?php
$get_attack = "SELECT `id`,`attack` FROM `stats` ORDER BY `attack` DESC";
$i = 1;
$rank = array();
$get_attack = mysqli_query($db_conx, $get_attack);
$numrows = mysqli_num_rows($get_attack);
while ($attack = mysqli_fetch_array($get_attack, MYSQLI_ASSOC)) {
$rank[$attack['id']] = $attack['attack'];
$sql = "UPDATE `ranking` SET `attack`='".$i."' WHERE `id`='".$attack['id']."'";
$i++;
}
$get_defense = "SELECT `id`,`defense` FROM `stats` ORDER BY `defense` DESC";
$i = 1;
$get_defense = mysqli_query($db_conx, $get_defense);
$numrows = mysqli_num_rows($get_defense);
while ($defense = mysqli_fetch_array($get_defense, MYSQLI_ASSOC)) {
$rank[$defense['id']] += $defense['defense'];
$sql = "UPDATE `ranking` SET `defense`='".$i."' WHERE `id`='".$defense['id']."'";
$i++;
}
asort($rank);
$rank2 = array_reverse($rank,true);
$i = 1;
foreach($rank2 as $key => $val){
$sql = "UPDATE `ranking` SET `overall`='".$i."' WHERE `id`='".$key."'";
$i++;
}
?>


Here is my page that calls the information:
Code: Select all
<?php
$sql = "SELECT `id`,`overall` FROM `ranking` WHERE `overall`>'0' ORDER BY `overall` ASC";
$user_query = mysqli_query($db_conx, $sql);
$numrows = mysqli_num_rows($user_query);
while ($row = mysqli_fetch_array($user_query, MYSQLI_ASSOC)) {
echo "<tr>";
echo "<td align='center'><font color='white'>" . $row['overall'] . "</font></td>";
$get_user = "SELECT `username` FROM `users` WHERE `id`='".$row['id']."'";
$rank_name = mysqli_fetch_assoc($get_user);
echo "<td align='center'><a href=\"mugstats.php?id=" .$row['id']."\"><font color='white'>" . $rank_name['username'] . "</font></a></td>";
$get_gold = "SELECT `gold` FROM `stats` WHERE `id`='".$row['id']."'";
$rank_gold = mysqli_fetch_assoc($get_gold);
echo "<td align='center'><font color='white'>" . number_format($rank_gold['gold']) . "</font></td>";
echo "</tr>";
}
?>