well i found my problem, or part of it.. It seems whenever i include this code with other includes that have other queries it freaks out.. Anyone see anything wrong with this small function? The problem is somewhere in here becuase it doesn't happen when i remove this function..
function template($templatesname)
{
global $templatescache;
$c=mysql_connect('host','user','pass') or die ( "Could not connet to MySQL" );
mysql_select_db(seby_content) or die ( "Could not connect to database" );
// check if template has already been loaded
if ($templatescache[$templatesname]!="") {
// return cached version
$templates = $templatescache[$templatesname];
} else {
$query = mysql_query("SELECT template FROM site_template WHERE title='$templatesname'");
if (mysql_num_rows($query)!=0) {
$templates = mysql_result($query,"template");
#replace \" with \\" ... this will be needed later in the script
$templates = str_replace("\"","\\\"",$templates);
// cache template
$templatescache[$name] = $templates;
} else {
$templates="";
}
}
return $templates;
mysql_close($c);
}