Manage Authors interface does not appear

Hello all you PHP people,
I am studying Kevin Yanks PHP/MySQL 4th ed. book and I am on page 202. Everything was working fine till I started this page. I’ve triple checked the code that I’ve typed to ensure that it is exactly as is in the book. I’ve ensured that the files are in the proper folders and that they are installed correctly in the htdocs folder on the Apache server.

The error message that returns is this:

Parse error: syntax error, unexpected ‘]’, expecting T_STRING or T_VARIABLE or T_NUM_STRING in E:\Program Files\Apache Software Foundation\Apache2.2\htdocs\admin\authors\index.php on line 15.

Next is the code from the index.php file that I typed:

// Display author list

include $_SERVER[‘DOCUMENT_ROOT’] . ‘/includes/’;
$result = mysqli_query($link, ‘SELECT id, name FROM author’);
if (!$result)
$error = "Error fetching authors from database’;
include ‘error.html.php’;

while ($row = mysqli_fetch_array($result))
$authors = array(‘id’ => $row[‘id’], ‘name’ => $row[‘name’]);

include ‘authors.html.php’;

Does anyone have a clue of what is causing the error message.

Thank you, Jim

hi Jim, it should be

$error = "Error fetching authors from database";

and not

$error = "Error fetching authors from database';

notice " and :slight_smile:


include $_SERVER['DOCUMENT_ROOT'] . '/includes/';
$result = mysqli_query($link, 'SELECT id, name FROM author');
if (!$result) {
$error = 'Error fetching authors from database';
include 'error.html.php';

$authors = array();

while ($row = mysqli_fetch_array($result)) {
$authors[] = array('id' => $row['id'], 'name' => $row['name']);

include 'authors.html.php';