By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,831 Members | 2,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,831 IT Pros & Developers. It's quick & easy.

output buffering, parse error unexpected t_string

P: n/a


I'm trying to use output buffering to cheat so i can print to excel
which is called later than this header().
header("Content-type: application/xmsdownload");
header("Content-Disposition: attachment;
header("Pragma: no-cache");
header("Expires; 0");
print "$header\n$data";
This is the header line it conflicts with so I surrounded it with the
buffer.
ob_start()
header( 'Content-type: text/html; charset=\"$CHARSET\"' );
obj_end_flush()
exit;

I have a question is this buffer supposed to go around the whole php
page or only the offending header line?

I am getting an error message on the header line " Parse error: syntax
error, unexpected T_STRING in /home/allrail/public_html/header.php on
line 39"

It worked before I put the buffer around it?

thanks,

Sep 26 '08 #1
Share this Question
Share on Google+
11 Replies


P: n/a
On 26 Sep, 22:20, JRough <jlro...@yahoo.comwrote:
I'm trying to use output buffering to cheat so i can *print to excel
which is called later than this header().

* * * * header("Content-type: application/xmsdownload");
* * * * header("Content-Disposition: attachment;
* * * * header("Pragma: no-cache");
* * * * header("Expires; 0");
* * * * print "$header\n$data";

This is the header line it conflicts with so I surrounded it with the
buffer.
ob_start()
header( 'Content-type: text/html; charset=\"$CHARSET\"' );
obj_end_flush()
exit;

I have a question is this buffer supposed to go around the whole php
page or only the offending header line?

I am getting an error message on the header line " Parse error: syntax
error, unexpected T_STRING in /home/allrail/public_html/header.php on
line 39"

It worked before I put the buffer around it?

thanks,
you have forgotton the semi-colons!
Sep 26 '08 #2

P: n/a
On Sep 26, 2:26*pm, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 26 Sep, 22:20, JRough <jlro...@yahoo.comwrote:
I'm trying to use output buffering to cheat so i can *print to excel
which is called later than this header().
* * * * header("Content-type: application/xmsdownload");
* * * * header("Content-Disposition: attachment;
* * * * header("Pragma: no-cache");
* * * * header("Expires; 0");
* * * * print "$header\n$data";
This is the header line it conflicts with so I surrounded it with the
buffer.
ob_start()
header( 'Content-type: text/html; charset=\"$CHARSET\"' );
obj_end_flush()
exit;
I have a question is this buffer supposed to go around the whole php
page or only the offending header line?
I am getting an error message on the header line " Parse error: syntax
error, unexpected T_STRING in /home/allrail/public_html/header.php on
line 39"
It worked before I put the buffer around it?
thanks,

you have forgotton the semi-colons!
oh thanks, it has been a long week but it still doesn't work? Now it
says ob_end_flush() is an undefined function.
"
Fatal error: Call to undefined function obj_end_flush() in /home/
allrail/public_html/header.php on line 40"

Why is that?
Sep 26 '08 #3

P: n/a
On Sep 26, 2:26*pm, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 26 Sep, 22:20, JRough <jlro...@yahoo.comwrote:
I'm trying to use output buffering to cheat so i can *print to excel
which is called later than this header().
* * * * header("Content-type: application/xmsdownload");
* * * * header("Content-Disposition: attachment;
* * * * header("Pragma: no-cache");
* * * * header("Expires; 0");
* * * * print "$header\n$data";
This is the header line it conflicts with so I surrounded it with the
buffer.
ob_start()
header( 'Content-type: text/html; charset=\"$CHARSET\"' );
obj_end_flush()
exit;
I have a question is this buffer supposed to go around the whole php
page or only the offending header line?
I am getting an error message on the header line " Parse error: syntax
error, unexpected T_STRING in /home/allrail/public_html/header.php on
line 39"
It worked before I put the buffer around it?
thanks,

you have forgotton the semi-colons!
okay, thanks, but I still have an error. Now it is on the preceeding
line 40.
It says obj_end_flush() is an undefined function.
"Fatal error: Call to undefined function obj_end_flush() in /home/
allrail/public_html/header.php on line 40"
How can I fix that?
Sep 26 '08 #4

P: n/a
On 26 Sep, 22:54, JRough <jlro...@yahoo.comwrote:
On Sep 26, 2:26*pm, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 26 Sep, 22:20, JRough <jlro...@yahoo.comwrote:
I'm trying to use output buffering to cheat so i can *print to excel
which is called later than this header().
* * * * header("Content-type: application/xmsdownload");
* * * * header("Content-Disposition: attachment;
* * * * header("Pragma: no-cache");
* * * * header("Expires; 0");
* * * * print "$header\n$data";
This is the header line it conflicts with so I surrounded it with the
buffer.
ob_start()
header( 'Content-type: text/html; charset=\"$CHARSET\"' );
obj_end_flush()
exit;
I have a question is this buffer supposed to go around the whole php
page or only the offending header line?
I am getting an error message on the header line " Parse error: syntax
error, unexpected T_STRING in /home/allrail/public_html/header.php on
line 39"
It worked before I put the buffer around it?
thanks,
you have forgotton the semi-colons!

okay, thanks, but I still have an error. *Now it is on the preceeding
line 40.
It says obj_end_flush() is an undefined function.
"Fatal error: Call to undefined function obj_end_flush() in /home/
allrail/public_html/header.php on line 40"
How can I fix that?
by using the correct function name. You really must pay attention to
what the errors say and start looking things up in the manual!
Sep 26 '08 #5

P: n/a
On 26 Sep, 22:54, JRough <jlro...@yahoo.comwrote:
On Sep 26, 2:26*pm, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 26 Sep, 22:20, JRough <jlro...@yahoo.comwrote:
I'm trying to use output buffering to cheat so i can *print to excel
which is called later than this header().
* * * * header("Content-type: application/xmsdownload");
* * * * header("Content-Disposition: attachment;
* * * * header("Pragma: no-cache");
* * * * header("Expires; 0");
* * * * print "$header\n$data";
This is the header line it conflicts with so I surrounded it with the
buffer.
ob_start()
header( 'Content-type: text/html; charset=\"$CHARSET\"' );
obj_end_flush()
exit;
I have a question is this buffer supposed to go around the whole php
page or only the offending header line?
I am getting an error message on the header line " Parse error: syntax
error, unexpected T_STRING in /home/allrail/public_html/header.php on
line 39"
It worked before I put the buffer around it?
thanks,
you have forgotton the semi-colons!

okay, thanks, but I still have an error. *Now it is on the preceeding
line 40.
It says obj_end_flush() is an undefined function.
"Fatal error: Call to undefined function obj_end_flush() in /home/
allrail/public_html/header.php on line 40"
How can I fix that?
Don't you think it's time that you realised that programming is not
your forte? You simply don't have the attention to detail or the
intelligence to carry it off.
Sep 26 '08 #6

P: n/a
On Sep 26, 3:00*pm, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 26 Sep, 22:54, JRough <jlro...@yahoo.comwrote:
On Sep 26, 2:26*pm, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 26 Sep, 22:20, JRough <jlro...@yahoo.comwrote:
I'm trying to use output buffering to cheat so i can *print to excel
which is called later than this header().
* * * * header("Content-type: application/xmsdownload");
* * * * header("Content-Disposition: attachment;
* * * * header("Pragma: no-cache");
* * * * header("Expires; 0");
* * * * print "$header\n$data";
This is the header line it conflicts with so I surrounded it with the
buffer.
ob_start()
header( 'Content-type: text/html; charset=\"$CHARSET\"' );
obj_end_flush()
exit;
I have a question is this buffer supposed to go around the whole php
page or only the offending header line?
I am getting an error message on the header line " Parse error: syntax
error, unexpected T_STRING in /home/allrail/public_html/header.php on
line 39"
It worked before I put the buffer around it?
thanks,
you have forgotton the semi-colons!
okay, thanks, but I still have an error. *Now it is on the preceeding
line 40.
It says obj_end_flush() is an undefined function.
"Fatal error: Call to undefined function obj_end_flush() in /home/
allrail/public_html/header.php on line 40"
How can I fix that?

by using the correct function name. You really must pay attention to
what the errors say and start looking things up in the manual!
sorry,
in any case, it now compiles and brings the page however, if I leave
the exit;
step I only get a blank web page, so I guess it exits all the way
out? if I leave the exit; step then I get the same error as before:
Warning: Cannot modify header information - headers already sent by
(output started at /home/allrail/public_html/header.php:40) in /home/
allrail/public_html/header.php on line 39

does that mean I can't use the buffer?
thanks,
Sep 26 '08 #7

P: n/a
On Sep 26, 3:23*pm, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 26 Sep, 22:54, JRough <jlro...@yahoo.comwrote:
On Sep 26, 2:26*pm, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 26 Sep, 22:20, JRough <jlro...@yahoo.comwrote:
I'm trying to use output buffering to cheat so i can *print to excel
which is called later than this header().
* * * * header("Content-type: application/xmsdownload");
* * * * header("Content-Disposition: attachment;
* * * * header("Pragma: no-cache");
* * * * header("Expires; 0");
* * * * print "$header\n$data";
This is the header line it conflicts with so I surrounded it with the
buffer.
ob_start()
header( 'Content-type: text/html; charset=\"$CHARSET\"' );
obj_end_flush()
exit;
I have a question is this buffer supposed to go around the whole php
page or only the offending header line?
I am getting an error message on the header line " Parse error: syntax
error, unexpected T_STRING in /home/allrail/public_html/header.php on
line 39"
It worked before I put the buffer around it?
thanks,
you have forgotton the semi-colons!
okay, thanks, but I still have an error. *Now it is on the preceeding
line 40.
It says obj_end_flush() is an undefined function.
"Fatal error: Call to undefined function obj_end_flush() in /home/
allrail/public_html/header.php on line 40"
How can I fix that?

Don't you think it's time that you realised that programming is not
your forte? You simply don't have the attention to detail or the
intelligence to carry it off.
sorry for the typos. Now it compiles and gives a blank page presumably
the exit; step? Without the exit step I get a fatal error to another
function on an included page. Does this mean that the buffer won't
work here?
Sep 26 '08 #8

P: n/a
JRough wrote:
On Sep 26, 2:26 pm, Captain Paralytic <paul_laut...@yahoo.comwrote:
>On 26 Sep, 22:20, JRough <jlro...@yahoo.comwrote:
>>I'm trying to use output buffering to cheat so i can print to excel
which is called later than this header().
header("Content-type: application/xmsdownload");
header("Content-Disposition: attachment;
header("Pragma: no-cache");
header("Expires; 0");
print "$header\n$data";
This is the header line it conflicts with so I surrounded it with the
buffer.
ob_start()
header( 'Content-type: text/html; charset=\"$CHARSET\"' );
obj_end_flush()
exit;
I have a question is this buffer supposed to go around the whole php
page or only the offending header line?
I am getting an error message on the header line " Parse error: syntax
error, unexpected T_STRING in /home/allrail/public_html/header.php on
line 39"
It worked before I put the buffer around it?
thanks,
you have forgotton the semi-colons!

oh thanks, it has been a long week but it still doesn't work? Now it
says ob_end_flush() is an undefined function.
"
Fatal error: Call to undefined function obj_end_flush() in /home/
allrail/public_html/header.php on line 40"

Why is that?
Because you have:

obj_end_flush();

Not

ob_end_flush();

But if you're trying to output an excel spreadsheet they bring up in
excel, you're going about it the wrong way. You can only have one
content type for a particular file, and this one needs to be text/html
(because you're also outputting html).

What you need to do is create another file which sets the content type
for THAT file

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

Sep 27 '08 #9

P: n/a
On Sep 26, 6:08*pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
On Sep 26, 2:26 pm, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 26 Sep, 22:20, JRough <jlro...@yahoo.comwrote:
>I'm trying to use output buffering to cheat so i can *print to excel
which is called later than this header().
* * * * header("Content-type: application/xmsdownload");
* * * * header("Content-Disposition: attachment;
* * * * header("Pragma: no-cache");
* * * * header("Expires; 0");
* * * * print "$header\n$data";
This is the header line it conflicts with so I surrounded it with the
buffer.
ob_start()
header( 'Content-type: text/html; charset=\"$CHARSET\"' );
obj_end_flush()
exit;
I have a question is this buffer supposed to go around the whole php
page or only the offending header line?
I am getting an error message on the header line " Parse error: syntax
error, unexpected T_STRING in /home/allrail/public_html/header.php on
line 39"
It worked before I put the buffer around it?
thanks,
you have forgotton the semi-colons!
oh thanks, it has been a long week but it still doesn't work? *Now it
says ob_end_flush() is an undefined function.
"
Fatal error: Call to undefined function obj_end_flush() in /home/
allrail/public_html/header.php on line 40"
Why is that?

Because you have:

obj_end_flush();

Not

ob_end_flush();

But if you're trying to output an excel spreadsheet they bring up in
excel, you're going about it the wrong way. *You can only have one
content type for a particular file, and this one needs to be text/html
(because you're also outputting html).

What you need to do is create another file which sets the content type
for THAT file

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
Are you saying that the content type of the excel print statement:

header("Content-type: application/xmsdownload");
conflicts with

the text type in the header?
header( 'Content-type: text/html; charset=\"$CHARSET\"' );

I don't know about the ob_start() and ob_end_flush() statement. It
didn't seem to work in this case. Everytime I used it with the exit
after the flush I got a blank page with nothing no header no footer,
nothing.
I just decided to do a hack and requeried the database for the excel
print. There are all these nested if's I can't get out of. All I
need is the $mark and $number and my hack works. I have a question
about this form:

form action="/clm_history.php" method="post">

<tr>

<td>
<table cellspacing="0" cellpadding="2" border="0"
class="content">
<tr><th colspan="7">Enter car mark and number to view CLM
history</th></tr>

<tr><td class=td3 align="right">Mark</td>
<td><input type=text name='mark' size=5></td>

<td class=td3 align="right">Number</td>
<td><input type=text name='num'></td>
</tr>
<tr>
<td></td>
<td></td>

<td></td>
<td align='right'><input type=submit class='button'
value='Get History'</td>
shouldn't $_POST['mark'] and $_POST['num'] be posted when the user
posts to the form? If I can get the posted value then my hack will
work and I can go home.

P.s. thanks for being nice.

This validate_login is at the beginning of the page:
Validate_login("clm_history.php?mark=".$mark."&num =".$num);

Does that mean $mark and $num aren't posted?
thanks,
Sep 27 '08 #10

P: n/a
JRough wrote:
On Sep 26, 6:08 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>JRough wrote:
>>On Sep 26, 2:26 pm, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 26 Sep, 22:20, JRough <jlro...@yahoo.comwrote:
I'm trying to use output buffering to cheat so i can print to excel
which is called later than this header().
header("Content-type: application/xmsdownload");
header("Content-Disposition: attachment;
header("Pragma: no-cache");
header("Expires; 0");
print "$header\n$data";
This is the header line it conflicts with so I surrounded it with the
buffer.
ob_start()
header( 'Content-type: text/html; charset=\"$CHARSET\"' );
obj_end_flush()
exit;
I have a question is this buffer supposed to go around the whole php
page or only the offending header line?
I am getting an error message on the header line " Parse error: syntax
error, unexpected T_STRING in /home/allrail/public_html/header.php on
line 39"
It worked before I put the buffer around it?
thanks,
you have forgotton the semi-colons!
oh thanks, it has been a long week but it still doesn't work? Now it
says ob_end_flush() is an undefined function.
"
Fatal error: Call to undefined function obj_end_flush() in /home/
allrail/public_html/header.php on line 40"
Why is that?
Because you have:

obj_end_flush();

Not

ob_end_flush();

But if you're trying to output an excel spreadsheet they bring up in
excel, you're going about it the wrong way. You can only have one
content type for a particular file, and this one needs to be text/html
(because you're also outputting html).

What you need to do is create another file which sets the content type
for THAT file
Are you saying that the content type of the excel print statement:

header("Content-type: application/xmsdownload");
conflicts with

the text type in the header?
header( 'Content-type: text/html; charset=\"$CHARSET\"' );
That's true. Each file the browser sees is fetched separately, and any
one file can only have a single content type.

For instance - your HTML page has a content type of text/html. If you
have an <img..tag, that points to another file whose content type
would be image/jpeg, image/gif, etc.

Your file needs to have content type of text/html. It cannot also have
a content type of application/xmsdownload.
I don't know about the ob_start() and ob_end_flush() statement. It
didn't seem to work in this case. Everytime I used it with the exit
after the flush I got a blank page with nothing no header no footer,
nothing.
It won't work, because you're trying to give that file two different
content types. That is not allowed.
>
I just decided to do a hack and requeried the database for the excel
print. There are all these nested if's I can't get out of. All I
need is the $mark and $number and my hack works. I have a question
about this form:

form action="/clm_history.php" method="post">

<tr>

<td>
<table cellspacing="0" cellpadding="2" border="0"
class="content">
<tr><th colspan="7">Enter car mark and number to view CLM
history</th></tr>

<tr><td class=td3 align="right">Mark</td>
<td><input type=text name='mark' size=5></td>

<td class=td3 align="right">Number</td>
<td><input type=text name='num'></td>
</tr>
<tr>
<td></td>
<td></td>

<td></td>
<td align='right'><input type=submit class='button'
value='Get History'</td>
shouldn't $_POST['mark'] and $_POST['num'] be posted when the user
posts to the form? If I can get the posted value then my hack will
work and I can go home.
Yes, they will. But you still can't have two content types for one file.
P.s. thanks for being nice.

This validate_login is at the beginning of the page:
Validate_login("clm_history.php?mark=".$mark."&num =".$num);

Does that mean $mark and $num aren't posted?
thanks,
No, $mark is not $_POST['mark']! (unless register_globals is on, which
is should NOT be).

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

Sep 27 '08 #11

P: n/a
On Sep 26, 7:15*pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
On Sep 26, 6:08 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
On Sep 26, 2:26 pm, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 26 Sep, 22:20, JRough <jlro...@yahoo.comwrote:
I'm trying to use output buffering to cheat so i can *print to excel
which is called later than this header().
* * * * header("Content-type: application/xmsdownload");
* * * * header("Content-Disposition: attachment;
* * * * header("Pragma: no-cache");
* * * * header("Expires; 0");
* * * * print "$header\n$data";
This is the header line it conflicts with so I surrounded it with the
buffer.
ob_start()
header( 'Content-type: text/html; charset=\"$CHARSET\"' );
obj_end_flush()
exit;
I have a question is this buffer supposed to go around the whole php
page or only the offending header line?
I am getting an error message on the header line " Parse error: syntax
error, unexpected T_STRING in /home/allrail/public_html/header.php on
line 39"
It worked before I put the buffer around it?
thanks,
you have forgotton the semi-colons!
oh thanks, it has been a long week but it still doesn't work? *Now it
says ob_end_flush() is an undefined function.
"
Fatal error: Call to undefined function obj_end_flush() in /home/
allrail/public_html/header.php on line 40"
Why is that?
Because you have:
obj_end_flush();
Not
ob_end_flush();
But if you're trying to output an excel spreadsheet they bring up in
excel, you're going about it the wrong way. *You can only have one
content type for a particular file, and this one needs to be text/html
(because you're also outputting html).
What you need to do is create another file which sets the content type
for THAT file
Are you saying that the content type of the excel print statement:
* *header("Content-type: application/xmsdownload");
conflicts with
*the text type in the header?
header( 'Content-type: text/html; charset=\"$CHARSET\"' );

That's true. *Each file the browser sees is fetched separately, and any
one file can only have a single content type.

For instance - your HTML page has a content type of text/html. *If you
have an <img..tag, that points to another file whose content type
would be image/jpeg, image/gif, etc.

Your file needs to have content type of text/html. *It cannot also have
a content type of application/xmsdownload.
I don't know about the ob_start() and ob_end_flush() statement. *It
didn't seem to work in this case. *Everytime I used it with the exit
after the flush I got a blank page with nothing no header no footer,
nothing.

It won't work, because you're trying to give that file two different
content types. *That is not allowed.


I just decided to do a hack and requeried the database for the excel
print. *There are all these nested if's I can't get out of. *All I
need is the $mark and $number and my hack works. *I have a question
about this form:
form action="/clm_history.php" method="post">
* * * * <tr>
* * * * <td>
* * * * <table cellspacing="0" cellpadding="2" border="0"
class="content">
* * * * <tr><th colspan="7">Enter car mark and number to viewCLM
history</th></tr>
* * * * <tr><td class=td3 align="right">Mark</td>
* * * * * * <td><input type=text name='mark' size=5></td>
* * * * * * <td class=td3 align="right">Number</td>
* * * * * * <td><input type=text name='num'></td>
* * * * </tr>
* * * * <tr>
* * * * * * <td></td>
* * * * * * <td></td>
* * * * * * <td></td>
* * * * * * <td align='right'><input type=submit class='button'
value='Get History'</td>
shouldn't $_POST['mark'] and $_POST['num'] be posted when the user
posts to the form? *If I can get the posted value then my hack will
work and I can go home.

Yes, they will. *But you still can't have two content types for one file.
P.s. *thanks for being nice.
This validate_login is at the beginning of the *page:
Validate_login("clm_history.php?mark=".$mark."&num =".$num);

It is not a separate php page. It is all on the same php page so the
scope should be okay.
But it branches from an if/else to the next page. I really don't know
why $mark and $num don't get passed any. It is a mystery. This query
is posted twice once for excel and once for the list. I also tried
making $result a global so I didn't have to query twice. That didn't
work either. Is that because it is an array?
thanks,
$result = SELECT_clm($mark,$num);
Validate_login("clm_history.php?mark=".$mark."&num =".$num);
if($_SESSION["LMS_USER_DESC"]=='customer'){
$id = $_SESSION["LMS_LOGGED_IN"];
}
if($mark&&$num){

$TPL_carnumbers = GetHeaders($_SESSION["LMS_USER_DESC"]);

$mark = $mark = strtoupper($mark);


# 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";

}

}else{

$template = "clm_history_php.html";

}

if ($_POST['assign']=='Open in Excel'){
$result = SELECT_clm($mark,$num);

$file_name = "CLM_History";



}
include "header.php";
include $template_path.$template;
include "footer.php";
Sep 28 '08 #12

This discussion thread is closed

Replies have been disabled for this discussion.