Jump to content


Photo

What am I doing wrong here?


  • Please log in to reply
2 replies to this topic

#1 alexville

alexville
  • Members
  • PipPipPip
  • Advanced Member
  • 71 posts

Posted 01 April 2006 - 02:50 PM

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Clues</title>
<style type="text/css">
<!--
body {
    background-color: #CCCCCC;
}
body,td,th {
    color: #000000;
    font-family: Arial, Helvetica, sans-serif;
}
.style1 {font-family: "Courier New", Courier, mono}
-->
</style></head>

<body>
<h1>Who Am I? Game</h1>
<h2>Clues</h2>
<hr>
<?php
// Get the 'username' varible from flash
$username = $_POST['username'];
$guessfirstname = $_POST['firstname'];
$guessid = $_POST['id'];
// Start database connection
$dbcnx = @mysql_connect("localhost","alexg_si","password");
if (!$dbcnx) {
echo "<p>Unable to connect to the database server at this time.</p>";
exit();
}
mysql_select_db("alexg_web",$dbcnx);
$result = @mysql_query("SELECT guessed, guessedright FROM whoamipeople WHERE id = '$guessid'");
if (!$result) {
exit("<p>Error performing query: " . mysql_error() . "</p>");
}
// Disply the users Account Details $row["Clue"]
while ($row = mysql_fetch_array($result)) {
$oldguessed = $row["guessed"];
$addingone = '1';
$newguessed = $oldguessed + $addingone;
$oldguessedright = $row["guessedright"];
$newguessedright = $oldguessedright + $addingone;
}
// done adding one
mysql_select_db("alexg_web",$dbcnx);
$resultupdateguess = @mysql_query("UPDATE whoamipeople SET guessed = '$newguessed', guessedright = '$newguessedright' WHERE Firstname = '$guessfirstname'");
$resultupdateguessisitright = @mysql_query("SELECT guessedright FROM whoamipeople WHERE id = '$guessid'");
while ($rowright = mysql_fetch_array($resultupdateguessisitright)) {
$oldguessedrightisitright = $rowright["guessedright"];
if ($oldguessedrightisitright == $newguessedright) {
echo "<p>Thank You, Processing Your Guess.</p>";
$resultupdateguesscorrect = @mysql_query("UPDATE whoamipeople SET score + 100 WHERE Username = '$username'");
echo "<p>Checking if guessed firstname is a match in the Who Am I? Database...</p>";
echo "<p>Yes! That is correct! You have gained 100 points. Check out your Account Info for your score!</p>";
} else {
echo "<p>Checking if guessed firstname is a match in the Who Am I? Database...</p>";
echo "<p>Sorry, that is the incorrect name. Nice Try!</p>";
}
// swich back to html mode to create divider
// 
?>
<h6 align="left"><span class="style1">Who Am I? Game is owned and created by Alex Grenier</span></h6>
<h6 align="left" class="style1">This pertictular verion is run by Alexville.com.</h6>
</html>

I get this error:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
Parse error: parse error, unexpected $ in /home/alexg/public_html/whoami/processguess.php on line 73[/quote]

The werid thing is that the 74 line only contains </html>

Thanks Guys

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 01 April 2006 - 03:14 PM

If you are getting that error message then you'll find that you have too many open and closing braces - {} - make sure they all pair up also make sure you parenthesis pair up too ()

One thing I can tell you that can help you make sure you braces pair up is indent your code. Have a look at your code now:
<?php
// Get the 'username' varible from flash
$username = $_POST['username'];
$guessfirstname = $_POST['firstname'];
$guessid = $_POST['id'];
// Start database connection
$dbcnx = @mysql_connect("localhost","alexg_si","password");

if (!$dbcnx)
{
    echo "Unable to connect to the database server at this time.";
    exit();
}
mysql_select_db("alexg_web", $dbcnx);
$result = @mysql_query("SELECT guessed, guessedright FROM whoamipeople WHERE id = '$guessid'");
if (!$result)
{
    exit("<p>Error performing query: " . mysql_error() . "</p>");
}
// Disply the users Account Details $row["Clue"]
while ($row = mysql_fetch_array($result))
{
    $oldguessed = $row["guessed"];
    $addingone = '1';
    $newguessed = $oldguessed + $addingone;
    $oldguessedright = $row["guessedright"];
    $newguessedright = $oldguessedright + $addingone;
}
// done adding one
mysql_select_db("alexg_web",$dbcnx);

$resultupdateguess = @mysql_query("UPDATE whoamipeople SET guessed = '$newguessed', guessedright = '$newguessedright' WHERE Firstname = '$guessfirstname'");
$resultupdateguessisitright = @mysql_query("SELECT guessedright FROM whoamipeople WHERE id = '$guessid'");

while ($rowright = mysql_fetch_array($resultupdateguessisitright))
{
    $oldguessedrightisitright = $rowright["guessedright"];

    if ($oldguessedrightisitright == $newguessedright)
    {
        echo "<p>Thank You, Processing Your Guess.</p>";

        $resultupdateguesscorrect = @mysql_query("UPDATE whoamipeople SET score + 100 WHERE Username = '$username'");

        echo "<p>Checking if guessed firstname is a match in the Who Am I? Database...</p>";
        echo "<p>Yes! That is correct! You have gained 100 points. Check out your Account Info for your score!</p>";
    }
    else
    {
        echo "<p>Checking if guessed firstname is a match in the Who Am I? Database...</p>";
        echo "<p>Sorry, that is the incorrect name. Nice Try!</p>";
    }
} //this was your missing backet!


// swich back to html mode to create divider
//
?>
As you can see your code is much more readable and easy to identify code blocks, just press your tab key once when you go into a code block, ie a if statement, while loop, creating functions etc.

#3 alexville

alexville
  • Members
  • PipPipPip
  • Advanced Member
  • 71 posts

Posted 01 April 2006 - 04:51 PM

Oh my god! IT WORKS! Thank you so much. Your a lifesaver.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users