Jump to content

Another Parse error (unexpected T_VARIABLE) [SOLVED]


James142

Recommended Posts

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

Link to comment
Share on other sites

  • Administrators

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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...