<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://librarian:passw0rd@localhost/library");
if (DB::iserror($db)) {
die($db->getMessage( ));
}
// issue the query
$sql = "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($sql);
if (DB::iserror($q)) {
die($q->getMessage( ));
}
// generate the table
while ($q->fetchInto($row)) {
?>
<tr><td><?= $row[0] ?></td>
<td><?= $row[1] ?></td>
<td><?= $row[2] ?></td>
</tr>
<?php
}
?>
Как должен выглядеть DB.php для запуска скрипта?
Это не работает:
<?php
define("DB_SERVER", "localhost");
define("DB_NAME", "***");
define ("DB_USER", "***");
define ("DB_PASSWORD", "***");
?>
Заранее спасибо