Jump to content

[SOLVED] Fatal error: Cannot redeclare headers()


newbtophp

Recommended Posts

Im getting this error, wherever I include the config file, anyone know what this maybe caused by?

 

Fatal error: Cannot redeclare headers() (previously declared in /home/mysite/public_html/config.php:9) in /home/mysite/public_html/config.php on line 17

 

Config.php:

 

<?php
//Include db connection
include "db.php";
db_connect();
$siteurl="http://mysite.com";
$sitename="Mysite Name";
$youremail="[email protected]";
$alloweduses="11";
$headerad="<img src=\"images/banner.gif\" border=0>";
function headers($from,$to,$subject)
{
return "MIME-Version: 1.0\r\n". //optional
   "Content-type: text/html; charset=iso-8859-1\r\n". //optional
   "From: \"".$from."\"\r\n". //required
   "To: \"Client\" <".$to.">\r\n".//required
   "Date: ".date("r")."\r\n".//optional
   "Subject: ".$subject."\r\n";//optional
} 
?>

 

db.php:

 

<?php
function db_connect()
{
$result = mysql_connect("localhost", "username", "password");
if(!$result)
return false;
if(!mysql_select_db("dbname"))
return false;

return $result;
}

?>

Fatal error: Cannot redeclare headers() (previously declared in /home/mysite/public_html/config.php:9) in /home/mysite/public_html/config.php on line 17

 

remove the headers() function from the config.php file and put it into a separate file afterwards call it using:

 

include_once('headers.php');

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.