Yet another error debug thread...

C++, C#, Java, PHP, ect...
Post Reply
120816
Posts: 2
Joined: Fri Mar 12, 2010 1:45 am

Yet another error debug thread...

Post by 120816 »

Hello all, let me just say I'm very impressed with the setup here and I find it great that you guys are taking time out to help out beginners like me interested in PHP. We all gotta start somewhere and I'm thankful for the helpful videos and tutorials available on a site like this.

Anyways, I'm extremely confused to why I'm getting this error. This is essentially taken from the source code in the MMO tutorial videos; hallsofvalhalla's register code. I just changed the variables name, database names and a few other to learn about how it works on PHP. Can someone explain to me why I get...

Parse error: parse error in C:\wamp\www\GuyOnline\RegisterUser.php on line 57...

Code: Select all

<?php
include 'RegisterConnect.php';
?>

<?php
$username=$_POST['username'];
$password=$_POST['password'];
$confirm=$_POST['confirm'];
$email=$_POST['email'];
$username=strip_tags($username);
$email=strip_tags($email);

if ($email == "")
{
echo "You didn't enter an email address!<br>";
echo " <br><A href='RegisterPage.php'>Go back.</a><br>";
    exit;
    }
if ($password==$confirm)
{

  $isplayer="SELECT * from playerinfotable where PlayerName='$username'";
  $isplayer2=mysql_query($isplayer) or die("Could not query players table.");
  $isplayer3=mysql_fetch_array($isplayer2);
  if(!$_POST['password'] || !$_POST['confirm'])
  {
     print "You did not enter a password.";
    echo " <br><A href='RegisterPage.php'>Go back.</a><br>";
    exit;
  }
  else if($isplayer3 || strlen($username)>15 || strlen($username)<1)
  {
     print "There is already a player of that name or the name you specified is over 16 letters or less than 1 letter.<br>";
     echo " <br><A href='RegisterPage.php'>Go back.</a><br>";
    exit;
  }
  else
  {
    $isaddress="SELECT * from playerinfotable where PlayerEmail='$email'";
    $isaddress2=mysql_query($isaddress) or die("Could not query for password.");
    $isaddress3=mysql_fetch_array($isaddress2);
    if($isaddress3)
    {
      print "There is already a player with that e-mail address.<br>";
      echo " <br><A href='RegisterPage.php'>Go back.</a><br>";
    exit;
    }
    else
    {
        $password=md5($password);

$SQL = "INSERT into playerinfotable(PlayerName, PlayerPassword, PlayerEmail) VALUES ('$username','$password','$email')";
      mysql_query($SQL) or die("Could not register.");

      print "Thank you for registering."; 
    }
  }                      //Line 57                                                                  =
}

else
{
  print "Your password didn't match or you did not enter a password.<br>";
   echo " <A href='register.php'>Go back</a>";
    exit;
}
echo "<br><br><A href='login.php'>Login Page</a>";
?>
When Line 57 is basically...

Code: Select all

$SQL = "INSERT into playerinfotable(PlayerName, PlayerPassword, PlayerEmail) VALUES ('$username','$password','$email')";
      mysql_query($SQL) or die("Could not register.");     

 print "Thank you for registering.";
    }    
  }      //Line 57                                                                                      =
}
Could someone point me in the right direction? I'm eager to learn.
ZeroComp
Posts: 648
Joined: Thu Oct 29, 2009 8:48 pm

Re: Yet another error debug thread...

Post by ZeroComp »

I think you have an extra brace, I'm just taking a stab at it if I'm wrong oh well
Coding-PHP, Javascript, C++, HTML, mySQL
Modeling/Art-Blender, GIMP
Games-Unity, Game Maker 8
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Yet another error debug thread...

Post by Jackolantern »

I am not immediately seeing anything jumping out at me. I copied your code into Codelobster for syntax highlighting, and it is usually pretty good about pointing out misspelled keywords, or mismatched braces.

What was that equal sign over to the right on line 57? Now that you commented line 57, it will not be a problem, but if that was there before you commented it, that could have been causing the issue. Remove that equal sign and the comment and see how it works.
The indelible lord of tl;dr
120816
Posts: 2
Joined: Fri Mar 12, 2010 1:45 am

Re: Yet another error debug thread...

Post by 120816 »

Oh God, I feel so stupid.

Thank you Jackolantern and ZeroComp. Some of us aren't naturally gifted at coding as you can see.
User avatar
MAruz
Posts: 117
Joined: Fri Nov 20, 2009 12:31 pm

Re: Yet another error debug thread...

Post by MAruz »

A good practice to avoid the bulk of these kinds of errors is to be strict on your indenting of code.

Every time you open up a "{", make sure the next line is indented with a tab (maybe 4 or 8 spaces if you prefer).
This way it's easier to see where a curly bracket belongs.

Halls doesn't do that in his tutorials, which can make it a bit hard to see where one block should start/end.

Also, software that highlights your syntax helps. Whit this kind of software, you can just click an opening curly bracket, and it will highlight the closing bracket that belongs to it.
PHP, Java, JavaScript, HTML, CSS, XML, MySQL / Oracle
Photoshop, Illustrator
www.cuddly-zombie.com
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Yet another error debug thread...

Post by hallsofvallhalla »

when I am doing large code with lots of braces i comment each brace

example

{////////////start of fight code

blah
blah

}///////////////end of fight code
jpoisson
Posts: 245
Joined: Sun Aug 02, 2009 5:12 pm

Re: Yet another error debug thread...

Post by jpoisson »

Halls method is probably the most effective.

I do that too sometimes, but I always open an close right away.
Post Reply

Return to “Coding”