Wrox Programmer Forums
|
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 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 September 8th, 2005, 11:52 AM
Registered User
 
Join Date: Sep 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ch9 charlist.php undefined index

Running XP sp2
4.0.25 MySQL
4.3.11 PHP
IIS

Chapter 9 charlist.php IF the syntax is correct then I just can not get it to run.

Notice: Undefined index: o in d:\inetpub\wwwroot\ch9\charlist.php on line 4
Unknown column 'p.power' in 'field list'

<?php
require('config.php');

$ord = $_GET['o'];
if (is_numeric($ord)){
$ord = round(min(max($ord, 1), 3));

} else {
$ord = 1;
}

$order = array(
    1 => 'alias ASC',
    2 => 'name ASC',
    3 => 'align ASC, alias ASC'
);

$conn = mysql_connect(SQL_HOST, SQL_USER, SQL_PASS) or die('Could not connect to MySQL database. ' .mysql_error());

mysql_select_db(SQL_DB,$conn);

$sql = "SELECT c.id, p.power FROM char_main c JOIN char_power p JOIN char_power_link pk ON c.id = pk.char_id AND p.id =

pk.power_id";

$result = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$p[$row['id']] [] = $row['power'];
}

foreach ($p as $key => $value) { $powers[$key] = implode(", ", $value);
}
}

$sql = "SELECT c.id, n.alias FROM char_main c JOIN char_good_bad_link
gb JOIN char_main n ON (c.id = gb.good_id AND n.id = gb.bad_id)
OR (n.id = gb.good_id AND c.id = gb.bad_id)";

$result = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$e[$row['id']][] = $row['alias'];

}

foreach ($e as $key => $value) {
$enemies[$key] = implode(",",$value);
}
}

$table = "<table><tr><td align=\"center\">No characters currently exist.</td></tr></table>"
?>


<html>
<head>
<title>Comic Book Appreciation</title>
</head>
<body>
<img src='CBA_Tiny.gif' align='left' hspace='10'>
<h1>Comic Book<br />Appreciation</h1><br />
<h3>Character Database</h3>

<?php
$sql = "SELECT id, alias, real_name AS name, align
FROM char_main ORDER BY ".$order[$ord];

$result = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($result) > 0) {
$table = "<table border='0' cellpadding='5'>";
$table .= "<tr bgcolor='#FFCCCC'><th>";
$table .= "<a href='" . $_SERVER['PHP_SELF'] . "?o=1'>Alias</a>";
$table .= "</th><th><a href='" . $_SERVER['PHP_SELF'] . "?o=2'>";
$table .= "Name</a></th><th><a href='" . $_SERVER['PHP_SELF'];
$table .= "<th>Enemies</th></tr>";

// build each table row
while ($row = mysql_fetch_assoc($result)) {
$bg = ($bg=='F2F2FF'?'E2E2F2':'F2F2FF');
$pow = ($powers[$row['id']]==''?'none':$powers[$row['id']]);
$ene = ($enemies[$row['id']]==''?'none':$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>";
}


$table .= "</table>";
$table = str_replace('evil', 'evil',$table);
$table = str_replace('good', 'good', $table);

}
echo $table;
?>

<br /><a href="charedit.php">New Character</a> &bull;
<a href="poweredit.php">Edit Powers</a>
</body>
</html>

Code was use from the book example. p.255
Any advice?

Thanks.




 
Old September 21st, 2005, 04:09 PM
Registered User
 
Join Date: Sep 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I started over with Apache 2.0.53 this time. Started over in the book to make sure apache was working. Ch2 - 9 No IIS this time.
Good news I can get charlist.php to run.
But I still get the message

Notice: Undefined index: o in E:\SERVER\Apache\Apache2\htdocs\ch9\charlist.php on line 4
Code is same as before.
Any ideas? Thanks

 
Old July 7th, 2006, 08:39 PM
Registered User
 
Join Date: Jul 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I get the same message, and can't figure out what's going on.






Similar Threads
Thread Thread Starter Forum Replies Last Post
undefined index and variable p3allen2000 Pro PHP 1 November 1st, 2007 04:49 PM
Undefined index junemo Pro PHP 8 October 31st, 2007 05:45 PM
Undefined Index Error rit01 Beginning PHP 0 March 1st, 2006 10:03 AM
chptr9 pg262 error with charlist.php richardh BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 12 August 11th, 2005 10:45 AM
Undefined index ashinotani Beginning PHP 2 August 17th, 2004 03:31 PM





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