473,326 Members | 2,175 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

redirect a print statement off a page so it doesn't conflict with aheader

I have this code that switches templates depending on if the user
fills in a form with a request. The request asks for the $mark &
$number. If that request gets input then it displays a list otherwise
it re-displays the form request. The $template variable changes the
value of which template is displayed.
if($mark&&$num){
$mark = $mark = strtoupper($mark);
$TPL_carnumbers = GetHeaders($_SESSION["LMS_USER_DESC"]);

$xclheader =
array('CLM_id','TRIP_id','Car_number','Sighting_Da te','Code','Location','','Location_Splc',
'L_E','railroad','Destination',
'','Destination_Splc','Car_number','',
'Classification','Origin', '','ETA');
$xclfields =
array('clm_id','trip_id','car_mark','car_number',' sighting_date','sighting_code',
'location_city','location_state','location_splc',' l_e','railroad','destination_city',
'destination_state','destination_splc',
'car_mark','car_number','classification','origin_c ity',
'origin_state',
'eta');
# GET CARS FOR GIVEN ID AND TYPE?
$result = SELECT_clm($mark,$num);

if(mysql_numrows($result)==0){
$TPL_error_value = "No Data for this Carnumber - Please Enter
Another Mark and Number";
$template = "clm_history_php.html";
}else{
while ($row = mysql_fetch_assoc($result)){
$TPL_carnumbers.=MakeSighting($_SESSION["LMS_USER_DESC"],$row);
}
}
$MSG_carlist = "SIGHTING HISTORY FOR ".MakeCarnumber($mark,$num);
$TPL_carnumbers.="</table>";
$template = "template_carlist.html";

if ($_POST['assign']!='Open in Excel'){
include "header.php";
include "footer.php";

}else{
$file_name = str_replace('.php?','',$file_name);
printxcl($data,$header,$file_name){
}
}else{
$template = "clm_history_php.html";
}

include "header.php";
include $template_path."$template";
include "footer.php";

I have an error in this page on the printxcl() function because there
is the earlier call to include the header.php page, On line 39 of
header.php page is
this line:
header( 'Content-type: text/html; charset=\"$CHARSET\"' );
which conflicts with the print statement in the printxcl() function.

How can I redirect that function /print statement to another page so I
don't get that error:

Warning: Cannot modify header information - headers already sent by
(output started at /home/allrail/public_html/templates/header.php.html:
15) in /home/allrail/public_html/header.php on line 39

Even though I tried moving the print statement to the function it
still hits on the page and I still get the error.

thanks very much,
Sep 26 '08 #1
2 2152
JRough wrote:
I have this code that switches templates depending on if the user
fills in a form with a request. The request asks for the $mark &
$number. If that request gets input then it displays a list otherwise
it re-displays the form request. The $template variable changes the
value of which template is displayed.
if($mark&&$num){
$mark = $mark = strtoupper($mark);
$TPL_carnumbers = GetHeaders($_SESSION["LMS_USER_DESC"]);

$xclheader =
array('CLM_id','TRIP_id','Car_number','Sighting_Da te','Code','Location','','Location_Splc',
'L_E','railroad','Destination',
'','Destination_Splc','Car_number','',
'Classification','Origin', '','ETA');
$xclfields =
array('clm_id','trip_id','car_mark','car_number',' sighting_date','sighting_code',
'location_city','location_state','location_splc',' l_e','railroad','destination_city',
'destination_state','destination_splc',
'car_mark','car_number','classification','origin_c ity',
'origin_state',
'eta');
# GET CARS FOR GIVEN ID AND TYPE?
$result = SELECT_clm($mark,$num);

if(mysql_numrows($result)==0){
$TPL_error_value = "No Data for this Carnumber - Please Enter
Another Mark and Number";
$template = "clm_history_php.html";
}else{
while ($row = mysql_fetch_assoc($result)){
$TPL_carnumbers.=MakeSighting($_SESSION["LMS_USER_DESC"],$row);
}
}
$MSG_carlist = "SIGHTING HISTORY FOR ".MakeCarnumber($mark,$num);
$TPL_carnumbers.="</table>";
$template = "template_carlist.html";

if ($_POST['assign']!='Open in Excel'){
include "header.php";
include "footer.php";

}else{
$file_name = str_replace('.php?','',$file_name);
printxcl($data,$header,$file_name){
}
}else{
$template = "clm_history_php.html";
}

include "header.php";
include $template_path."$template";
include "footer.php";

I have an error in this page on the printxcl() function because there
is the earlier call to include the header.php page, On line 39 of
header.php page is
this line:
header( 'Content-type: text/html; charset=\"$CHARSET\"' );
which conflicts with the print statement in the printxcl() function.

How can I redirect that function /print statement to another page so I
don't get that error:

Warning: Cannot modify header information - headers already sent by
(output started at /home/allrail/public_html/templates/header.php.html:
15) in /home/allrail/public_html/header.php on line 39

Even though I tried moving the print statement to the function it
still hits on the page and I still get the error.

thanks very much,
You can't call header() after any output has been sent to the client.
And you can't redirect output in php to another page - the best you can
do is buffer the output and perhaps throw it away. However, that hides
the problem, not fixes it.

You need to restructure your code so you don't try to call header()
after output has been sent to the browser.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 26 '08 #2
On Sep 26, 1:59*am, JRough <jlro...@yahoo.comwrote:
I have this code that switches templates depending on if the user
fills in a form with a request. The request asks for the $mark &
$number. If that request gets input then it displays a list otherwise
it re-displays the form request. *The $template variable changes the
value of which template is displayed.
if($mark&&$num){
* $mark = $mark = strtoupper($mark);
* $TPL_carnumbers = GetHeaders($_SESSION["LMS_USER_DESC"]);

* * * * * * * * $xclheader =
array('CLM_id','TRIP_id','Car_number','Sighting_Da te','Code','Location','','Location_Splc',
'L_E','railroad','Destination',
'','Destination_Splc','Car_number','',
* * * * *'Classification','Origin', '','ETA');
* * * * * * * * $xclfields =
array('clm_id','trip_id','car_mark','car_number',' sighting_date','sighting_code',
* * * * * * * * * * * * 'location_city','location_state','location_splc',' l_e','railroad','destination_city',
'destination_state','destination_splc',
'car_mark','car_number','classification','origin_c ity',
'origin_state',
* * * * * * * * * * * * 'eta');

* # GET CARS FOR GIVEN ID AND TYPE?
* $result = SELECT_clm($mark,$num);

* if(mysql_numrows($result)==0){
* * $TPL_error_value = "No Data for this Carnumber *- *Please Enter
Another Mark and Number";
* * $template = "clm_history_php.html";
* }else{
* * * * while ($row = mysql_fetch_assoc($result)){
* * * $TPL_carnumbers.=MakeSighting($_SESSION["LMS_USER_DESC"],$row);
* * * * }
* }
* * $MSG_carlist = "SIGHTING HISTORY FOR ".MakeCarnumber($mark,$num);
* * $TPL_carnumbers.="</table>";
* * * * $template = "template_carlist.html";

* * * * if ($_POST['assign']!='Open in Excel'){
* * * * include "header.php";
* * * * include "footer.php";

* * * * }else{
* * * * * * * * $file_name = str_replace('.php?','',$file_name);
* * * * * * * * printxcl($data,$header,$file_name){
* * * * }}else{

* * * * $template = "clm_history_php.html";

}

include "header.php";
include $template_path."$template";
include "footer.php";

I have an error in this page on the printxcl() function because there
is the earlier call to include the header.php page, * On line 39 of
header.php page is
this line:
header( 'Content-type: text/html; charset=\"$CHARSET\"' );
which conflicts with the print statement in the printxcl() function.

How can I redirect that function /print statement to another page so I
don't get that error:

Warning: Cannot modify header information - headers already sent by
(output started at /home/allrail/public_html/templates/header.php.html:
15) in /home/allrail/public_html/header.php on line 39

Even though I tried moving the print statement to the function it
still hits on the page and I still get the error.

thanks very much,
The quick and dirty workaround is to use output buffering to defer the
sending of data to the browser until you've sent your headers.

The correct way of doing it is to rearrange your code so it doesn't
send any output before it's done sending headers.
Sep 26 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sentinel | last post by:
here is the entire thread From: "Kimmo Laine" <eternal.erectionN0.5P@Mgmail.com> Subject: Re: script in body Date: Mon, 20 Jun 2005 17:46:28 +0300 Message-ID:...
2
by: bagsmode | last post by:
Hi, I'm trying to set a session cookie and then redirect, however I get the error: Status: 302 Moved Location: /index.cgi I thought I recall getting an error like this when I first tried...
5
by: Steve Lutz | last post by:
Hello, I have a page that creates a class, and then on certain conditions, redirects user to another page. The class has a Class_Terminate() function that saves itself to a database. The class...
13
by: Tim | last post by:
Hello, Is there a way to "cancel" a response.Redirect? For example, in the code below, could I insert anything in the Catch statement that would cancel the redirect and resume flow after the...
4
by: Greg Scharlemann | last post by:
I thought I had a workable approach to specifing which pages required a redirect in a config file, but it appears the way I'm attempting to do it is not going to work. The idea is that I can...
5
by: Doug | last post by:
In the code below, I am trying to go from one asp page to another: For Each tripToAccept As String In tripsToAccept.Split("/"c) dataManager.UpdateTripDetail("Accept", CInt(tripToAccept),...
18
by: Paul Lautman | last post by:
JRough wrote: What do you mean by "redirect the output to Excel"??? Excel isn't a location, it's a spreadsheet program that some (but not all users) will have on their machine. BTW, Location:...
2
by: dmorand | last post by:
When I try to print a 'print version' of my page it looks fine in IE 7, but when I print in IE 6 the margins are all screwed up. The page itself looks the same in both browsers, it's just when I...
0
by: JRough | last post by:
I have the following code at the end of a page that lists some query results. It starts in a form that asks the user for input, one of two template pages. One template is a form for user input if...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.