Distortion Posted October 15, 2009 Report Share Posted October 15, 2009 (edited) I'm getting an unexpected '{' error at line 64 but I can't see why... can you?Oh and any other comment or suggestion on my code is welcome. <?php// Check inputif ($name || $password) { if (!($name)) { print("Exuse me, but I think you forgot to fill in your name. Please try again <a href='login.php'>here</a> "); } else if (!($password)) { print("Exuse me, but I think you forgot to fill in your password. Please try again <a href='login.php'>here</a> "); } else { // Compare to database $query = "SELECT * FROM username WHERE name='$name' AND password='$password'"; $result = mysql_query($query); if ($data = mysql_fetch_array($result)) { print("There is allready a user with that name. Please choose another name <a href='register.php'> here </a>"); } else { // Insert into table $sql = "INSERT INTO userdata(name,password,points,money) VALUES('$name','$password','$points',$money)"; $result = mysql_query($sql); // Close connection $break = mysql_close($connection); // Display text on page print "Thank you sir, you can access your bank account <a href='play.php'> here </a>"[b]line 64-->[/b] } }} Edited October 15, 2009 by Distortion Link to comment Share on other sites More sharing options...
jeffman Posted October 15, 2009 Report Share Posted October 15, 2009 You're missing a semi-colon after your last print statement. The interpreter doesn't expect a closing brace before a semi-colon to end the statement. Link to comment Share on other sites More sharing options...
Distortion Posted October 15, 2009 Author Report Share Posted October 15, 2009 I feel very stupid now.Thanks.The weird thing is that a simular script on my other site (which I largely copied) also misses the last semicolon, and does not give an error. Link to comment Share on other sites More sharing options...
jeffman Posted October 15, 2009 Report Share Posted October 15, 2009 (edited) The semi-colon is not required in the final statement before a closing ?> tag. Maybe that's what you saw? It's not recommended, though, since any modifications might neglect to add the semicolon. The only useful exception might be "one-liners" like <?php echo "hello" ?>, but even there a lot of programmers do it. If you never make exceptions, you'll never do it wrong. Edited October 15, 2009 by Deirdre's Dad Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now