Um one thing in regard to the manner in which you are doing your queries and the way that they said to fix it.
Code:
// rather than
"select * from ".$table." where userid='".$userid."'"
// or
"select * from $table where userid=$userid
// you should do it this way, rembering that this, after all a string, and is parsed as such, before being sent as a query, thus:
"select * from $table where userid='$userid'
// or for something complicated the following:
"select * from $table where specialrow='specialid{$userid}'"
I know that this is really a mute issue, but using variables directly without quotes for a varchar or other entry would have problems if there is a space, or whatever, thus having them encapsulated with single- or escaped double- quotes, would be the proper way to avoid this problem.
Nice hack btw.