<?


function connect() {

  global $conn;

  $conn = mysql_connect( hostname, username, password  );

  if( !$conn ) {
	  echo "Couldn't connect to database!<BR>";
  }

    mysql_select_db(dbname);
}

function query($query) {
  // do query

  global $conn;

  $result = mysql_query($query, $conn);


  if (!$result) {
      echo "Invalid SQL: ".$query." :: ".$conn;
  }

  return $result;
}

function fetch($result) {

   if (isset($result)) {

     $row = mysql_fetch_array($result);

   } else {

     echo "Invalid Query Fetch";

   }

    return $row;
}

function num_rows($result) {

   // returns number of rows in query
   return mysql_num_rows($result);
}

function close() {

  // closes connection to the database

  return mysql_close();
}

function dooutput($template) {

    echo $template;

}

function storeoutput($template) {

    global $admincontent;

    $admincontent .= $template;

}

function gettemplate($templatedir,$template,$endung="html") {

    //echo "templatedir = ".$templatedir;
    //echo "<br>Template= ".$template;
    return str_replace("\"","\\\"",implode("",file($templatedir.$template.".".$endung)));

}

?>