Looks like you arn't connected to the db when calling those queries.
I'd check your db_connect() function to make sure it works, unless thats a PHP function (I'm rusty as anything) in which case it needs some variables, like host name!
$db = mysql_pconnect("hostname", "username", "password");
mysql_select_db("db_name",$db);
Try that to connect, changing the things to whatever they need to be of course.