Jump to content

Another Parse error (unexpected T_VARIABLE) [SOLVED]


Recommended Posts

Posted

After about 30 minutes (no exaggeration) of trying to fix this error, I am still coming up empty handed. Hopefully someone here can help me...

When I use this code:

<?php $getid = $_GET['user']
$rs = mysql_query("select 'name','age','country' from users where id='$getid' LIMIT 1"); <--- THIS IS LINE 9
list($name, $age, country) = mysql_fetch_row($rs);    ?>

I get the following message: Parse error: syntax error, unexpected T_VARIABLE in "bla bla bla" on line 9. (line 9 is the second line in the code above)

I do know that the error means that I am missing one of these characters: ' ; ' " ) ( [ ] ...But I dont know which one(s) I am missing and where they belong..

Perhaps someone could point out what I have done wrong?

Kindest Regards,

James

Posted

If I am not mistaken in the last line, shouldn't country have the dollar sign in front too? Also the first line is not ended ;) you forgot to put the ';' at the end of $_GET['user'].

  • Like 1
Posted

Would you look at that, it works!

Thanks guys!

<?php $getid = $_GET['user'];
$rs = mysql_query("SELECT 'name','age','country' FROM users WHERE id='$getid' LIMIT 1"); 
list($name, $age, $country) = mysql_fetch_row($rs);    ?>

Kindest Regards,

James

  • Administrators
Posted

BTW you should do


$getid = mysql_real_escape_string($_GET['user']);
$rs = mysql_query("SELECT 'name','age','country' FROM users WHERE id='$getid' LIMIT 1"); 
list($name, $age, $country) = mysql_fetch_row($rs);

Otherwise, you're ripe for SQL injection attack.

Posted

BTW you should do


$getid = mysql_real_escape_string($_GET['user']);
$rs = mysql_query("SELECT 'name','age','country' FROM users WHERE id='$getid' LIMIT 1"); 
list($name, $age, $country) = mysql_fetch_row($rs);

Otherwise, you're ripe for SQL injection attack.

Thanks Nabeel!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...