Parse error: syntax error, unexpected T_VARIABLE in line 8
Ok, firstly I am pretty new to PHP so I am really just learning. I have an user login page that seems to keep throwing me errors. Specifically:
Parse error: syntax error unexpected T_VARIABLE in line 8. this is the snippet of code: include_once 'srheader.php'; echo "<h3>User Log In</h3>"; $error = $user = $pass = ""; if (isset($_POST['user']) { $user = sanitizeString($_POST['user']); $pass = sanitizeString($_POST['pass']); if ($user == "" || $pass == "") { $error = "Not all fields were entered<br /> } else { $query = "SELECT user,pass FROM users where user='$user' AND pass='$pass'"; if (mysql_num_rows(queryMysql($query)) == 0) { $error = "Username/Password Invalid<br />"; } else { $_SESSION['user'] = $user; $_SESSION['pass'] = $pass; die ("You are now logged in. Please <a href='rnmembers.php?view=$user'>Click Here</a>."); } } } echo <<<_END Line 8 is: $user = sanitizeString($_POST['user']); I am stuck. Can anyone see what I did wrong? Thanks!!!!! |
Are you using a text editor that does syntax highlighting? ... any syntax errors should show up clearly then.
|
Please use php and /php markups, you are a web developper, no ?
PHP Code:
|
Quote:
|
Think like a parser ... which means, sometimes, "totally stupid." :)
If you are a parser, then you are in the business of trying to match-up some arbitrary bit of incoming text to some arbitrary grammar (which is a formal description of what "the language that you're supposed to be processing" is "supposed" to look like). Now, every now and again, a syntax-error occurs, and when it does, "you fall down." But, simpleton that you are, you can only report the line-number where you actually fell, not where the original error occurred. Quote:
The moral of this story is thus: when any language compiler (or interpreter) seems to be telling you that "an error has occurred 'here,'" what it is actually saying is that the incontrovertible existence of an error has been discovered 'here.'" The actual point of failure is likely to be somewhere earlier, as in this case. All that you know for certain is that "it is nearby." PHP uses state-of-the-art parser technology, and pretty much everyone else does, too. Therefore, "don't blame PHP," and, really, don't blame yourself either. :) They are all like this. Quote:
|
DOH!
Thanks, I must have looked at that blasted thing for 20 minutes and never noticed the missing ). I cleared that up and am now throwing a could of other errors but think I will work through them before posting.
Thanks for your help! |
Ok, new problem (sorry I am learning via trial by fire here). I fixed the parenthesis in my code and now am getting:
Parse error: syntax error, unexpected T_IS_EQUAL in index5.php on line 19 below is the nearby code: if(isset($_POST['user'])) { $user = sanitizeString($POST['user']); $pass = sanitizeString($POST['pass']); if ($user == "" | $pass == "") { $error = "Not all fields entered<br />"; } else { $query = "SELECT user,pass FROM users WHERE user='$user' and pass='$pass'"; if (mysql_num_rows(queryMysql($query))) == 0 { $error = "Username/Password invalid<br />"; } else { $_SESSION['user'] = $user; $_SESSION['pass'] = $pass; die("You are now logged in"); } } } Line 19 is: if (mysql_num_rows(queryMysql($query))) == 0 I've done a few pages but this login page is killing me. |
HAHAHAHAA I found it all by myself! I am sure I will end up posting again, but for now I will celebrate with a victory beer.
|
Have you not noticed the colour change in your editor? .. try this line for a start:
Code:
if (mysql_num_rows(queryMysql($query)) == 0 You also seem to have lost your underscores in: Code:
$user = sanitizeString($_POST['user']); |
All times are GMT -5. The time now is 09:39 AM. |