Welcome to Dream.In.Code
Become a PHP Expert!

Join 136,913 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,738 people online right now. Registration is fast and FREE... Join Now!




[Solved] Unexpected '{' Error

 
Reply to this topicStart new topic

[Solved] Unexpected '{' Error, Can't fix problem...

sf242
22 Mar, 2008 - 05:50 AM
Post #1

New D.I.C Head
*

Joined: 17 Jul, 2007
Posts: 42


My Contributions
I am attempting to write a blog script for my site, and this is the page to login to add a new post.
CODE
<?php
if (isset($_POST['username']) && isset($_POST['password']) {
include ("settings.php");
$u = $_POST['username'];
$p = $_POST['password'];
if ($u == $usercheck && $p == $passcheck) {
echo "<script language=\"javascript\" type=\"text/javascript\">
window.location=\"?bpage=addpost\";
</script>";
}
else {
die ("Incorrect username or password.");
}
}
else {
?>
<h3>Login to Add a New Post</h3>
<br>
<form method="POST" action="<?php $_SERVER['php-self']; ?>">
<h4>Username</h4>
<input type="text" name="username" />
<br>
<h4>Password</h4>
<input type="password" name="password" />
<br>
<input type="submit" value="Login" />
</form>
<?php
}
?>

Whenever I try to run it, I get the error "Parse error: syntax error, unexpected '{' in /homepages/19/d224217279/htdocs/eric/blog/login.php on line 2". How can I fix this? I don't see whats wrong here.
User is offlineProfile CardPM
+Quote Post

sf242
RE: [Solved] Unexpected '{' Error
22 Mar, 2008 - 06:21 AM
Post #2

New D.I.C Head
*

Joined: 17 Jul, 2007
Posts: 42


My Contributions
Never mind, I fixed it by splitting it into 2 separate pages then editing a bit of it...
User is offlineProfile CardPM
+Quote Post

spearfish
RE: [Solved] Unexpected '{' Error
22 Mar, 2008 - 07:35 AM
Post #3

Monkey in Training
Group Icon

Joined: 10 Mar, 2008
Posts: 746



Thanked: 2 times
Dream Kudos: 225
My Contributions
The error was in that first conditional statement. You don't combine them like that.

CODE
if (isset($_POST['username']) && isset($_POST['password']) {


should be:

CODE
if (isset($_POST['username']) && isset($_POST['password']) ) {


You forgot to close the conditional statement, thus it wasn't expecting the } so soon.

This post has been edited by spearfish: 22 Mar, 2008 - 07:35 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 10:03PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month