Jump to content

Archived

This topic is now archived and is closed to further replies.

alexville

What am I doing wrong here?

Recommended Posts

[code]<!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> [/code]

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

Share this post


Link to post
Share on other sites
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:
[code]<?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
//
?>[/code]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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.