Chapter 10 - powers and enemies
I followed the book (entering the code) and input Powers to the char_power table.
Then I created the first and only Character choosing 1 or 2 powers. This character has no enemies. An error is thrown because $enemies is not defined in char_transact.php. (I copied the downloaded char_transact.php file so I did not create any typo errors.)
The statement - if($enemies != '') {
then etc;
fails.
I fixed this with the following:
if (isset($enemies) && $enemies != '') {
etc;
Also if you update the character and do not select any Powers then $powers is undefined.
I changed - if($powers != "") {
to the following:
if (isset($powers) && $powers != "") {
etc;
In charlist.php I made the following change to skip $powers if it is not set (defined):
//$pow = ($powers[$row['id']]=='' ? 'none' :$powers[$row['id']]);
if(!isset($powers) || ($powers[$row['id']]== ''))
{
$pow = 'none';
}
else{
$pow = $powers[$row['id']];
}
When I click the character link in charlist.php to edit my character charedit.php comes up with all the data filled in except there are no Powers selected. To make any update (or none at all) the Powers have to be re-selected. I have not figured out how to fix this.
I would be glad of help if somebody out there has the answer to this problem.
Regards,
Al
|