Greetings,
When I execute this code the table appears as [Book | Year Published | Author] and nothing else. I get no errors from Apache2.2 or MySQL.I am using Windows xp Home edition, English. If I use viewsource the table reads <tr><td><?= $row[0] ?></td><td><?= $row[1] ?></td><td><?= $row[2] ?></td></tr> etc. I have tapped all resources such as thescripts,mysql ref,php.net,Pear and many forums trying to solve the mystery. The code is from oreillys "Programming PHP Second Edition." Example 8-1. Display Book Information page 199. Any help would be appreciated.
Sincerely, Richard M.
code:
[php]
<html><head><title>Library Books</title></head>
<body>
<table border=1>
<tr><th>Book</th><th>Year Published</th><th>Author</th></tr>
<?php
// connect
require_once('DB.php');
$db = DB::connect("mysql://root:rich@localhost/library");
if (DB::iserror($db)) {
die($db->getMessage());
}
// issue the query
$mysql = "SELECT books.title,books.pub_year,authors.name
FROM books, authors
WHERE books.authorid=authors.authorid
ORDER BY books.pub_year ASC";
$q = $db->query($mysql);
if (DB::iserror($q)) {
die($q->getMessage());
}
error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
// generate the table
while ($q->fetchInto($row)) {
?>
<tr><td><?= $row[0] ?></td>
<td><?= $row[1] ?></td>
<td><?= $row[2] ?></td>
</tr>
<?php
}
?>
</table>
</body></html>[/php]
Read the Posting Guidelines before you post in this forum!
Especially the part about enclosing code within [php] or [code] tags!!
moderator