function query($sql) {
    $sql = trim($sql);
    if (strlen($sql) == 0) return 0;
    if (!$this->connect()) return 0;  // connection problems
    $this->result = @mysql_query($sql, $this->_cnx);
    if (mysql_errno()) $this->_handleError("Invalid SQL: ".$sql);
    return $this->result;
}