views:

25

answers:

4
+2  Q: 

PHP Error T_STRING

Parse error: syntax error, unexpected T_STRING in /opt/lampp/htdocs/Community/register.php on line 84

I get that error, here is line 84 of my code.

   if ($firstname && $lastname && $username && $email && $password && $repassword){

        if ($password == $repassword){
                if (strstr($email, "@") && strstr($email, ".") && (strlen($email) >= 6)) {
                        require("scripts/connect.php");
                        $query = mysql_query("SELECT * FROM users WHERE username='$username'); 
                        $numrows = mysql_num_rows($query); 
                        if ($numrows == 0){ $query = mysql_query("SELECT * FROM users WHERE email='$email'"); 
                        }
                }
        }
}

Any ideas as to how I can fix this?

A: 

There is a missing " here:

$query = mysql_query("SELECT * FROM users WHERE username='$username'");
                                                                    ^
codaddict
A: 

Okay, thanks for all of your help, I've fixed it now!

Nullbyte
A: 

I got it. Never closed the string of the first query:

"SELECT * FROM users WHERE username='$username');

Notice missing close quotation.

I suggest using a syntax highlighting text editor.

tandu
A: 

I see by the code pasted in your (hard to read) comment that the problem is on a line several lines before the line posted in your question which is missing a close quote. The line that reads:

$query = mysql_query("SELECT * FROM users WHERE username='$username');

should be:

$query = mysql_query("SELECT * FROM users WHERE username='$username'");

And BTW, you may want to do some research on SQL injection as I believe your code may have some vulnerabilities.

Asaph