chap10 - If a hero has no enemies
I found out another mistake on line 82 of charlist.php
In case you don't select any enemy related to a superhero, the following code returns an undefined index error, because it looks for $enemies[$row['id']] that is not set:
if (!isset($enemies) || ($enemies[$row['id']]=='')) {
$ene = 'none';
} else {
$ene = $enemies[$row['id']];
}
}
$table .= "<tr bgcolor=\"#" . $bg . "\">" .
"<td><a href=\"charedit.php?c=" . $row['id'] . "\">" .
$row['alias']. "</a></td><td>" .
$row['name'] . "</td><td align=\"center\">" .
$row['align'] . "</td><td>" . $pow . "</td>" .
"<td align=\"center\">" . $ene . "</td></tr>";
So I changed it as follows and it works!
if(!isset($enemies[$row['id']]) || ($enemies[$row['id']] =='')) {
$ene='none';
} else{
$ene = $enemies[$row['id']];
}
...
:D
|