Header already sent error in PHP joomla
$dbhost = 'localhost';
$dbuser = 'EhpEngineUser';
$dbpass = 'password';
$conn = mysql_pconnect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = 'joomladb';
mysql_select_db($dbname);
// include 'config.php';
// include 'opendb.php';
above code works fine,开发者_运维问答 if i comment DB connection part and inculde config.db and Opendb, then i get the error as
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\Joomla\Config.php:8) in C:\xampp\htdocs\Joomla\ConfXml.php on line 103
Both file are used for opening DB only.
This is a common Problem, it may be due to extra spaces getting printed or any other characters...
Solution is simple
Check your PHP.ini file for
output_buffering = Off
set it to
output_buffering = On
If you don't have access to PHP.ini then you can use output buffering functions to buffer your output automatically before sending any output
<?php
ob_start(); //Start of page
//Entire page content
ob_end_flush(); //End of page
?>
This should solve your problem
"header already sent" error may caused by some extra space/linefeed after your php ending tag ?>
try to remove ending tag ?>
in C:\xampp\htdocs\Joomla\Config.php
You may used echo and header within same page. thats why error comes.
精彩评论