I am learning PHP from Kevin Yank's book "Build your own Database driven Website using PHP and MySQL" and have progressed upto Chapter 6 with the help of my friends at SitePoint.
I am now stuck with the code for the file, authors.php which allows administrators to add new authors and delete and edit existing ones.
I am giving the body of my code below:
<body>
<h1>Manage Authors</h1>
<p align="center"><a href="newauthor.php">Create New Author</a></p>
<ul>
PHP Code:
<?php
// Connect to DB server
$dbcnx = mysql_connect("localhost","root");
if(!$dbcnx)
{
die('<p>Unable to connect to the ' .
'database servre at this time.</p>');
}
// Select the jokes database
mysql_select_db('jokes');
// Request the list of all the authors
$authors = @mysql_query("SELECT ID, Name FROM Authors");
if (!$authors) {
die('<p>Error performing query: ' . mysql_error() .
'.</p>;
}
// Display the name of each author
while ($author = mysql_fetch_array($authors)) {
// I am getting an error on the following line
$id = $author['ID'];
$name = $author['Name'];
echo('<li>' . $name .
"[<a href='editauthor.php?id=$id'>Edit</a>]" .
"<a href='deleteauthor.php?id=$id'>Delete</a>]".
'</li>');
}
?>
</ul>
<p align="center"><a href="admin.html">Return to Front Page</a></p>
</body>
I am getting an error in the line mentioned above as follows:
Parse error: parse error, unexpected T_STRING
Can you please help me to find out where I am going wrong?
Bookmarks