9
The user load function is very heavy, would use up more resources and return more data than required, Here is a nice little function for you:
function get_uid($username)
{
// Function that returns the uid based on the username given
$user = db_fetch_object(db_query("SELECT uid FROM users WHERE name=':username'", array(":username" => $username)));
return $user->uid;
}
Note: This code is revised and input is escaped, so the code is not dangerous in any way.