|  |
03-19-2005, 03:30 PM
|
#1 (permalink)
|
Super Techie Join Date: Nov 2004 Posts: 338
| Need Help in PHP I am new to PHP and I was trying to change my meta tags and I get this error:
Warning: Cannot modify header information - headers already sent by (output started at /home2/cincopho/public_html/album/index.php:3) in /home2/cincopho/public_html/album/themes/hardwired/theme.php on line 893
This is what it says on line 893:
header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
then I get this one:
Warning: Cannot modify header information - headers already sent by (output started at /home2/cincopho/public_html/album/index.php:3) in /home2/cincopho/public_html/album/include/functions.inc.php on line 51
line 51 says:
setcookie($CONFIG['cookie_name'].'_data', $data, time()+86400*30, $CONFIG['cookie_path']);
Please Help!
__________________
Intel Core 2 Quad Q9300
Intel DX48BT2
Visiontek ATI HD3870 X2
WD Velociraptor 300 GB
6GB CORSAIR XMS3 1600 MHz DDR3 PC 12800
LG Flatron W2252 22" LCD
Corsair 1000 Watt
Windows 7 Ultimate |
| |
03-19-2005, 05:20 PM
|
#2 (permalink)
|
Super Techie Join Date: Mar 2005 Posts: 259
| You can't send header info after page data is already sent. That is what is happening. As the first line in your script, call ob_start(). Then as the last line, ob_end_clean(). That is the fastest solution.
__________________ Christopher Ingram
Principal Consultant, Souken Group, LLC.
C.Ingram@SoukenGroup.com
(856) 392 5244 -- (866) Go Souken |
| |
03-19-2005, 06:02 PM
|
#3 (permalink)
|
Super Techie Join Date: Nov 2004 Posts: 338
| so where do I put the meta tags? Do I delete those lines? I am tottally new to PHP but I know HTML
__________________
Intel Core 2 Quad Q9300
Intel DX48BT2
Visiontek ATI HD3870 X2
WD Velociraptor 300 GB
6GB CORSAIR XMS3 1600 MHz DDR3 PC 12800
LG Flatron W2252 22" LCD
Corsair 1000 Watt
Windows 7 Ultimate |
| |
03-19-2005, 06:19 PM
|
#4 (permalink)
|
Super Techie Join Date: Mar 2005 Posts: 259
| If they are HTML meta-tags, place them in as your normally would.
__________________ Christopher Ingram
Principal Consultant, Souken Group, LLC.
C.Ingram@SoukenGroup.com
(856) 392 5244 -- (866) Go Souken |
| |
03-19-2005, 06:29 PM
|
#5 (permalink)
|
Super Techie Join Date: Nov 2004 Posts: 338
| Here is the code from line 1 to 25:
<head>
<meta name="description" content="my description here...">
<meta name="keywords" content="my keywords here....">
</head>
<?php
$DIR=preg_split("/[\/\\\]/",dirname($_SERVER['PATH_TRANSLATED']));
if ($DIR[count($DIR)-2] == "modules") {
echo "<html><body><h1>ERROR</h1>You installed the standalone Coppermine into your Nuke portal.
".
"Please download and install a CPG Port: <a href=\"http://sourceforge.net/project/showfiles.php?group_id=89658\">CPG for PostNuke OR CPG for PHPnuke</a></body></html>";
die();
} // end check
define('IN_COPPERMINE', true);
define('INDEX_PHP', true);
require('include/init.inc.php');
if ($CONFIG['enable_smilies']) include("include/smilies.inc.php");
/**
* Local functions definition
*/
function html_albummenu($id)
__________________
Intel Core 2 Quad Q9300
Intel DX48BT2
Visiontek ATI HD3870 X2
WD Velociraptor 300 GB
6GB CORSAIR XMS3 1600 MHz DDR3 PC 12800
LG Flatron W2252 22" LCD
Corsair 1000 Watt
Windows 7 Ultimate |
| |
03-19-2005, 06:46 PM
|
#6 (permalink)
|
Super Techie Join Date: Mar 2005 Posts: 259
| Yeah, that's fine. Throw your additional meta tags in with the current ones. Only use header() to send HTTP headers to the browser. using ob_start() and ob_end_flush() are still good ideas though, as it seems you throw a cookie out where you probably shouldn't.
__________________ Christopher Ingram
Principal Consultant, Souken Group, LLC.
C.Ingram@SoukenGroup.com
(856) 392 5244 -- (866) Go Souken |
| |
03-19-2005, 08:25 PM
|
#7 (permalink)
|
Super Techie Join Date: Nov 2004 Posts: 338
| as I said I am new to PHP and I didn't write this code. All I added was the meta tags which I did as it looks above and when I do that then I get the error.
__________________
Intel Core 2 Quad Q9300
Intel DX48BT2
Visiontek ATI HD3870 X2
WD Velociraptor 300 GB
6GB CORSAIR XMS3 1600 MHz DDR3 PC 12800
LG Flatron W2252 22" LCD
Corsair 1000 Watt
Windows 7 Ultimate |
| |
03-19-2005, 08:54 PM
|
#8 (permalink)
|
Monster Techie Join Date: May 2004 Location: Tucson, AZ, USA Posts: 1,183
| <head>
<meta name="description" content="my description here...">
<meta name="keywords" content="my keywords here....">
</head>
<?php
$DIR=preg_split("/[\/\\\]/",dirname($_SERVER['PATH_TRANSLATED']));
if ($DIR[count($DIR)-2] == "modules") {
echo "<html><body><h1>ERROR</h1>You installed the standalone Coppermine into your Nuke portal.
".
"Please download and install a CPG Port: <a href=\"http://sourceforge.net/project/showfiles.php?group_id=89658\">CPG for PostNuke OR CPG for PHPnuke</a></body></html>";
die();
} // end check
define('IN_COPPERMINE', true);
define('INDEX_PHP', true);
require('include/init.inc.php');
if ($CONFIG['enable_smilies']) include("include/smilies.inc.php");
/**
* Local functions definition
*/
function html_albummenu($id)
should be...
<?php
$yournewcode = '
\n<head>\n
<meta name="description" content="my description here...">\n
<meta name="keywords" content="my keywords here....">\n
</head>\n
';
$DIR=preg_split("/[\/\\\]/",dirname($_SERVER['PATH_TRANSLATED']));
if ($DIR[count($DIR)-2] == "modules") {
echo "<html>$yournewcodehere<body><h1>ERROR</h1>You installed the standalone Coppermine into your Nuke portal.
".
"Please download and install a CPG Port: <a href=\"http://sourceforge.net/project/showfiles.php?group_id=89658\">CPG for PostNuke OR CPG for PHPnuke</a></body></html>";
die();
} // end check
define('IN_COPPERMINE', true);
define('INDEX_PHP', true);
require('include/init.inc.php');
if ($CONFIG['enable_smilies']) include("include/smilies.inc.php");
/**
* Local functions definition
*/
function html_albummenu($id)
You cannot add headers directly to that because PHP needs to be able to send/alternate them at that point (or the code your using, at least). So to get around it...you need to insert the metatags into the PHP code directly, so what I did was first create a new variable "yournewcode", set it to the stuff you wanted, then placed the variable in the PHP output,
echo "<html>$yournewcodehere<body>...
since your code has the head tag...it'd go after <html> and before <body>...
simple as that, if I made any sense (I hope I did)...! The \n means next line, just to make the HTML look a little better (FYI).
__________________ |
| |
03-23-2005, 01:38 PM
|
#9 (permalink)
|
Junior Techie Join Date: Mar 2005 Posts: 55
| The problem is, is that as soon as information is sent from the sever to the browser, the headers come along with it. Here is the process of executing a PHP script:
PC --(request webpage)--> Sever - outputs html
Sever --(goes to php parser change php into html)-->PHP parser - is told to output stuff
PHP parser --(Sends HTML to SEVER)--> Sever
Sever --(Sends HTML to PC)--> PC
(The page is not fully loaded, so the process repeats)
When the page sends information from the sever to the PC the header information comes with it. In your script you telling it to resend the header information multiple times and therefore it is causing an error, as it can't. Instead you should send the headers first and then the remaining script.
Consider this script:
<?php
echo "Hello";
echo "<head><meta name = "blah"></head>";
?>
It will report an error because you are resending the headers.
However this would work:
<?php
echo "<head><meta name = "blah"></head>";
echo "Hello";
?>
Here the headers are only being sent once. I hope that helps.
*note, this is what I am lead to believe. If I am incorrect please put me right* |
| |
03-27-2005, 10:15 PM
|
#10 (permalink)
|
Newb Techie Join Date: Mar 2005 Posts: 20
| first off, it is better to print all your html at the end, and have it saved in a variable, then put all your html in a skin file, but use the EOF tags instead, and i do not see why you need to send out header information if you are printing out an html page... |
| |  | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | |