O'Reilly Forums: Chapter 6 - Page 328 - 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 328 Trouble with approving the scores

#1 User is offline   Big Lew 

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

Posted 04 June 2014 - 04:40 PM

I am having trouble with the admin page where it is suppossed to approve the scores. For some reason, the code will change the value for approved from 0 to 1. As a result, I am unable to display any scores on the main page. I went through all the code in chapter's 5 and 6 to compare it to my code and I saw no discrepancies. After running the pages, I go the database and see that the approved column in the guitarwars table doesn't change to 1. I went ahead and manually changed the code to 1 and run the home page and the scores and images are displayed. If it makes a difference I will go ahead and show the code for approvescore.php:

<?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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Approve Score</title>
</head>

<body>

<?php

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


if (isset($_POST['submit'])) {
if($_POST['confirm']=='Yes') {
// Connect to the database
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

// Approve the score by setting the approved column in the database
$query = "UPDATE guitarwars SET approved = 1 WHERE id = '$id' ";
mysqli_query($dbc, $query);
mysqli_close($dbc);

// Confirm success with the user
echo '<p>The high score of ' . $score . 'for' . $name . 'was successfully approved.</p>';
}
else {
echo '<p class="error">Sorry, there was a problem approving the high score.</p>';
}
}

echo '<p><a href="admin.php">&lt;&lt; Back to the administration page</a></p>';

?>
</body>
</html>



Please help me with this. It would really mean a great deal to me.

Thank you
0

#2 User is offline   Big Lew 

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

Posted 05 June 2014 - 10:03 AM

I want to add a correction to the second sentence in the first paragraph. I meant to say, "For some reason, the code will not change the value for approved from 0 to 1."
0

#3 User is offline   lemuel 

  • Super Veteran Member
  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 577
  • Joined: 13-April 09

Posted 06 June 2014 - 10:01 AM

Have you echo-ed $query to make sure it's doing what you want it to do?
0

#4 User is offline   Big Lew 

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

Posted 06 June 2014 - 01:27 PM

View Postlemuel, on 06 June 2014 - 10:01 AM, said:

Have you echo-ed $query to make sure it's doing what you want it to do?

Actually, I was able to solve the problem. I cross-referenced it to the code I downloaded and noticed there were a few discrepancies that were not mentioned in the book. These author's are step skippers.
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