Wrox Programmer Forums
|
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0
This is the forum to discuss the Wrox book Beginning PHP5, Apache, and MySQL Web Development by Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz, Michael K. Glass; ISBN: 9780764579660
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 25th, 2008, 05:17 AM
Registered User
 
Join Date: May 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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







Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 10 - powers and enemies GranDad BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 September 18th, 2005 09:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.