I think you have to follow advices of bradgrafelman in his previous post.
Why you add double quote around ".$uname." ?
If you keep a lot to solve the problem just do:
$sql = sprintf(
"SELECT username FROM members WHERE `id` = %d LIMIT 1",
mysql_real_escape_string([COLOR="Red"]"[/COLOR].$userid.[COLOR="Red"]"[/COLOR])
);
have to be :
$sql = sprintf(
"SELECT username FROM members WHERE `id` = %d LIMIT 1",
mysql_real_escape_string($userid)
);
And :
$sql = sprintf(
"SELECT * FROM users WHERE `uname` = %s LIMIT 1",
[COLOR="Red"] "[/COLOR].$uname.[COLOR="Red"]"[/COLOR]
)
have to be :
$sql = sprintf("SELECT * FROM users WHERE `uname` = %s LIMIT 1", $uname);