PHP error.

taekwondokid42

New Member
Messages
268
Reaction score
0
Points
0
Parse error: syntax error, unexpected T_STRING in /home/mike/public_html/loginp.php on line 13


Line 13 reads like this:

$sql = SELECT FROM users WHERE name == "$username" AND pass == "$password";

what is the problem?

There are no syntax errors in the line above or below it.
 

sms_dre

New Member
Messages
18
Reaction score
0
Points
0
you need single quote marks round the whole query as its a string (and you're already using doubles inside the string):

$sql = 'SELECT FROM users WHERE name == "$username" AND pass == "$password"';
 

deadimp

New Member
Messages
249
Reaction score
0
Points
0
Be sure to sanitize (escape) your strings to prevent MySQL injection!
 

*Face

New Member
Messages
62
Reaction score
0
Points
0
Code:
$sql = 'SELECT FROM users WHERE name == "$username" AND pass == "$password"';
That doesn't look like it'll actually work, since PHP doesn't parse variables in strings with single quotes.
Code:
$sql = 'SELECT FROM users WHERE name == "'.$username.'" AND pass == "'.$password.'"';
This should work, always assuming you have proper protection in place.
 

conker87

New Member
Messages
65
Reaction score
0
Points
0
Or do it the logical way:

Code:
$sql = "SELECT FROM users WHERE name = '$username' AND pass = '$password'";

I've never seen '==' used ever in MySQL.
 
Last edited:

taekwondokid42

New Member
Messages
268
Reaction score
0
Points
0
Thank you.

I like the last way the best. And if you were wondering, I got the script working now.:biggrin:
 
Top