Page 1 of 1

Simple Login Script error

Posted: Fri Mar 25, 2005 3:23 pm
by anthony88guy
I am trying to make a simple login script, but i am getting an error on line 16: Parse error: parse error, unexpected T_STRING

Posted: Fri Mar 25, 2005 3:33 pm
by feyd
your query string isn't a string.

Posted: Fri Mar 25, 2005 3:35 pm
by anthony88guy
I would need quotes? Likes this?

Posted: Fri Mar 25, 2005 3:38 pm
by phpScott
anthony88guy wrote:I would need quotes? Likes this?

Code: Select all

$registered = mysql_query("SELECT * FROM users WHERE user = "$user" && pass = "$pass"") or die(mysql_error());
no now you have syntax errors. Try

Code: Select all

$registered = mysql_query("SELECT * FROM users WHERE user = '$user' && pass = '$pass'") or die(mysql_error());

Posted: Fri Mar 25, 2005 3:39 pm
by anthony88guy
ok, thanks i am a total noob. Why can't my way work?

Posted: Fri Mar 25, 2005 3:45 pm
by feyd
the first way isn't a string. The second, if you look at the highlighted version you posted, doesn't parse right.

Posted: Fri Mar 25, 2005 3:47 pm
by Ambush Commander
Because without escaping your quote characters PHP sees this:

Code: Select all

"SELECT * FROM users WHERE user = "

$user

" && pass = "

$pass

""
And there's no concatenation, so PHP throws a parse error.

Posted: Fri Mar 25, 2005 4:17 pm
by anthony88guy
ok, thxs