mysql_fetch_object出错

In my log i see next error

mysql_fetch_object(): supplied argument is not a valid MySQL result resource in mysql.class.php on line 37

Here is code with line 37

function findpole1($id,$table){

   mysql_connect($GLOBALS["hostname"],$GLOBALS["username"],$GLOBALS["password"]) or die("");
   $result=mysql_db_query($GLOBALS["dbname"],"SELECT * FROM $table WHERE id='$id'");

   //*****************line38********************************

    $find=mysql_fetch_row($result);
    echo $find[2];

}

and part of code with mysql_fetch_object in the same file

static  function query($sql,$default=0){

    if ($default==1) { echo '<div style="border: solid 1px red">'.$sql.'</div>'; }

    $result=mysql_query($sql);

    $a=array();
    while ($obj = mysql_fetch_object($result)) {
                $a[]=$obj;
    }

    return $a;

}

Please help me check this error