I create my code on my own machine and tested it on my own machine and everything worked perfectly fine but as soon as I uploaded it to my server it seems to have stopped working. None of the code has been changed except for the database user, pass and name.
This is the error I am encountering;
mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/pmoore/domains/moorepaul.com/public_html/suggest/includes/database.php on line 66
That section of code is as follows;
public function fetch_array($result) {
$table_result=array();
$r=0;
while($row = mysql_fetch_assoc($result)){
$arr_row=array();
$c=0;
while ($c < mysql_num_fields($result)) {
$col = mysql_fetch_field($result, $c);
$arr_row[$col -> name] = $row[$col -> name];
$c++;
}
$table_result[$r] = $arr_row;
$r++;
}
return $table_result;
}
and the section of code calling the function;
foreach ($games as $game) {
$gamefix = str_replace(' ', '+', $game);
$sql = "SELECT `Achievement` FROM `" . $gamefix . "`";
$result_set = $database->query($sql);
$achievements = $database->fetch_array($result_set);
echo "<h4>{$game}</h4>";
foreach ($achievements as $achievement) {
echo $achievement['Achievement'] . "<br />";
}
}