Ok, what is going wrong with my script is; When i set an error, it displays once, but it's added twice on the db.. This is the error handler functions: ----------------------------> function setError($type = 'notis', $message = NULL) { global $sql_prefix; if($message) { if(!isset($_SESSION['error_log'])) { $_SESSION['error_log'] = array(); } if(!isset($_SESSION['error_log'][$type])) { $_SESSION['error_log'][$type] = array(); } $_SESSION['error_log'][$type][] = $message; $url_input = __IPUBLISHER_CURRENT_URL; $dateoferror = date("Y-m-d H:i:s"); $user_inuse = BRUKER_ID; if($type != "message") { $query = "INSERT INTO {$sql_prefix}error_log (id,type,message,url,user,dato) VALUES ('','{$type}','{$message}','{$url_input}', '{$user_inuse}', '{$dateoferror}')"; @mysql_query($query); } } return isset($_SESSION['error_log']) ? $_SESSION['error_log'] : NULL; } // Read errors that are set function readError($type = NULL) { $errors = setError(); if($errors = setError()) { if($type) { unset($_SESSION['error_log'][$type]); return array($type => $errors[$type]); } else { unset($_SESSION['error_log']); return $errors; } } return array(); } ------------- Now theese all seem to work, the problem starts when i include a file with ob_get_contents This is two functions from the template system ------------> function fetch($fil) { ob_start(); include $fil; $inc = ob_get_contents(); ob_end_clean(); return $inc; } function output_page($side) { global $lng; $apne = read_url($this->tpl_mappe.'/'.$side); foreach($this->tpl_vars as $navn => $verdi) { $apne = $this->erstatt($navn, $verdi, $apne); } $apne = preg_replace('{\{(.*?)\}}', '', $apne); return $apne; } ----------- All this is combined like this setError('error', 'This is just an test'); $t->add('show_error', showErrors(readError())); $t->add('content', $t->fetch('ipub-pages/'.__IPUB_CATEGORY__.'/'.__IPUB_SUBPAGE__.'.inc.php')); echo $t->output_page("template.tpl"); --- This will add the error twice in the db, but if i comment out the "content", everything works, and the error is only inserted once.. But.. I need to use the fetch function to get the content in the right place. :(