O'Reilly Forums: Chapter 6 (page 326) - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Chapter 6 (page 326)

#1 User is offline   Big Lew 

  • Active Member
  • PipPip
  • Group: Members
  • Posts: 10
  • Joined: 03-January 14

Posted 03 June 2014 - 05:10 PM

I uploaded the code for admin.php from page 326, but when I run it on a browser, I get the following error message:

Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /home/biglew/public_html/admin.php on line 41


Here is the code I have:


<?php
require_once('authorize.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Guitar Wars - High Scores Administration</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<h2>Guitar Wars - High Scores Administration</h2>
<p>Below is a list of all Guitar Wars high scores. Use this page to remove scores as needed.</p>
<hr />

<?php
require_once('appvars.php');
require_once('connectvars.php');

// Connect to the database
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

// Retrieve the score data from MySQL
$query = "SELECT * FROM guitarwars ORDER BY score DESC, date ASC";
$data = mysqli_query($dbc, $query);

// Loop through the array of score data, formatting it as HTML
echo '<table>';
while ($row = mysqli_fetch_array($data)) {
// Display the score data
echo '<tr class="scorerow"><td><strong>' . $row['name'] . '</strong></td>';
echo '<td>' . $row['date'] . '</td>';
echo '<td>' . $row['score'] . '</td>';
echo '<td><a href="removescore.php?id=' . $row['id'] . '&amp;date=' . $row['date'] .
'&amp;name=' . $row['name'] . '&amp;score=' . $row['score'] .
'&amp;screenshot=' . $row['screenshot'] . '">Remove</a>';
if ($row['approved']=='0') {
echo '/<a href="approvescore.php?id='.$row['id'].'&amp;date='.$row['date'].
'&amp;name='.$row['name'].'&amp;score='.$row['score'].'&amp;screenshot='
$row['screenshot']. '">Approve</a>';
}

echo '</td></tr>';
}
echo '</table>';

mysqli_close($dbc);
?>

</body>
</html>



Based on the error message, this is line 41: $row['screenshot']. '">Approve</a>';


I do not know why I am getting this message. It sounds like it might need a semicolon or a comma somewhere, but I combed through the code and compared it to the book. I figure maybe another set of eyes might be able to find it. It is probably a very simple solution, but I am having a frustrating time at it. Is there anybody out there who can help me?

This post has been edited by Big Lew: 03 June 2014 - 05:11 PM

0

#2 User is offline   Big Lew 

  • Active Member
  • PipPip
  • Group: Members
  • Posts: 10
  • Joined: 03-January 14

Posted 04 June 2014 - 05:02 AM

View PostBig Lew, on 03 June 2014 - 05:10 PM, said:

I uploaded the code for admin.php from page 326, but when I run it on a browser, I get the following error message:

Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /home/biglew/public_html/admin.php on line 41


Here is the code I have:


<?php
require_once('authorize.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Guitar Wars - High Scores Administration</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<h2>Guitar Wars - High Scores Administration</h2>
<p>Below is a list of all Guitar Wars high scores. Use this page to remove scores as needed.</p>
<hr />

<?php
require_once('appvars.php');
require_once('connectvars.php');

// Connect to the database
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

// Retrieve the score data from MySQL
$query = "SELECT * FROM guitarwars ORDER BY score DESC, date ASC";
$data = mysqli_query($dbc, $query);

// Loop through the array of score data, formatting it as HTML
echo '<table>';
while ($row = mysqli_fetch_array($data)) {
// Display the score data
echo '<tr class="scorerow"><td><strong>' . $row['name'] . '</strong></td>';
echo '<td>' . $row['date'] . '</td>';
echo '<td>' . $row['score'] . '</td>';
echo '<td><a href="removescore.php?id=' . $row['id'] . '&amp;date=' . $row['date'] .
'&amp;name='. $row['name'] . '&amp;score=' . $row['score'] .
'&amp;screenshot=' . $row['screenshot'] . '">Remove</a>';
if ($row['approved']=='0') {
echo '/<a href="approvescore.php?id='.$row['id'].'&amp;date='.$row['date'].
'&amp;name='.$row['name'].'&amp;score='.$row['score'].'&amp;screenshot='
$row['screenshot']. '">Approve</a>';
}

echo '</td></tr>';
}
echo '</table>';

mysqli_close($dbc);
?>

</body>
</html>



Based on the error message, this is line 41: $row['screenshot']. '">Approve</a>';


I do not know why I am getting this message. It sounds like it might need a semicolon or a comma somewhere, but I combed through the code and compared it to the book. I figure maybe another set of eyes might be able to find it. It is probably a very simple solution, but I am having a frustrating time at it. Is there anybody out there who can help me?



Disregard the message. I was able to figure what was wrong and fixed it.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users