Minor semantic issue:
leatherback;10985269 wrote:then your query is not executing.
Technically, it is executing - it's just failing due to an error with the syntax.
@: Take a look at the PHP error message you showed us. It's telling you that you didn't give [man]mysql_fetch_array/man a valid MySQL result resource in the function's parameter list. In other words, $result does not contain a valid MySQL result resource.
Since $result contains the value returned from [man]mysql_query/man, you should visit the manual page for that function and see what types of values that function will return. You'll then see that a boolean FALSE return value indicates an error with your query.
Whenever there is an error with your query, you should be examining the error message returned by MySQL (see [man]mysql_error/man) as well as perhaps echo'ing out the SQL query itself (as leatherback is suggesting) so that you can visually inspect it to make sure it looks like what you expected it to.
By the way, you should also ensure that display_errors is set to On and error_reporting is set to E_ALL, because then you would have been alerted to the fact that $_SESSION['userid'] doesn't exist. It doesn't exist because you never called [man]session_start/man to start the session.