Error connecting to database table

When I run a SQL query on the id & name from my “author” table in my database, the result generates a list of names. But in my php code, i receive the error message that it is unable to fetch the authors from the database. I know the authors are there so why can’t this code retrieve the names? The code is typed below.


<?php

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

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

include 'authors.html.php'; 
?>

Keep an eye on this thread: http://www.sitepoint.com/forums/showthread.php?t=697261 as they have the same problem.
:slight_smile:

This problem seems to be rather common.

In addition to the above linked thread, Please try Searching using the vBulletin Advanced Search and SitePoint’s [URL=“http://search.sitepoint.com/”]Advanced Search

It is also being discussed here http://www.sitepoint.com/forums/showthread.php?t=697660

To minimize confusion and make it easier for others to help, please do not start more than one thread dealing with the same topic.

Thanks