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

[PHP 5 XP IE6]header("test"); does not display

P: n/a
Hi,
I'm trying a simple form.html that call a .html script that begins
with:

<?php
header("This is a test");
?>

When I click on the link, I get blank page.

I tried every combination of .html and .php as extensions, none works.

I checked the >Tools>Config>advanced menus in IE6, I can't find where
could be some filter to prevent the headers from displaying.

************************************************** ***********
I say without reservation, we ain't getting no hi-higher
It's a girl Mrs Walker it's a girl
************************************************** ***********

Mar 23 '06 #1
Share this Question
Share on Google+
10 Replies


P: n/a

universalbitmapper wrote:
Hi,
I'm trying a simple form.html that call a .html script that begins
with:

<?php
header("This is a test");
?>

When I click on the link, I get blank page.

I tried every combination of .html and .php as extensions, none works.

I checked the >Tools>Config>advanced menus in IE6, I can't find where
could be some filter to prevent the headers from displaying.

************************************************** ***********
I say without reservation, we ain't getting no hi-higher
It's a girl Mrs Walker it's a girl
************************************************** ***********


What are you trying to do? Just make it output "This is a test" ?

If you want the file to be parsed as php, give it a .php extension. If
you want the page to display "This is a test" then it should just be
this:

<?php
echo "This is a test.";
?>

Mar 23 '06 #2

P: n/a
universalbitmapper wrote:
Hi,
I'm trying a simple form.html that call a .html script that begins
with:

<?php
header("This is a test");
?>

When I click on the link, I get blank page.

I tried every combination of .html and .php as extensions, none works.

Hmm.... To elaborate on the other reply slightly, header("Test"); will
output "Test" into the http headers. The headers are the bit that tell
the browser that it's about to receive a file or a web page etc and is
to all intents and purposes, invisisible to the end user. As a rough
rule, you wont need to use the header() function until you're fairly
advanced with PHP, with possibly the exception of header("Location:
anotherpage.htm"); that which redirects the browser to anotherpage.
If you want to display text to the user (browser) then use echo "Test";

Good luck.

Mar 23 '06 #3

P: n/a
universalbitmapper wrote:
Hi,
I'm trying a simple form.html that call a .html script that begins
with:

<?php
header("This is a test");
?>

When I click on the link, I get blank page.

I tried every combination of .html and .php as extensions, none works.

I checked the >Tools>Config>advanced menus in IE6, I can't find where
could be some filter to prevent the headers from displaying.

************************************************** ***********
I say without reservation, we ain't getting no hi-higher
It's a girl Mrs Walker it's a girl
************************************************** ***********

Two things:

1. 'a simple form.html that call a .html script'.
Shouldn't that be a .php script?

2. 'header("This is a test");'
Try echo "This is a test";

-david-

Mar 23 '06 #4

P: n/a
Treefrog wrote:

As a rough
rule, you wont need to use the header() function until you're fairly
advanced with PHP, with possibly the exception of header("Location:
anotherpage.htm"); that which redirects the browser to anotherpage.


When you use the location header, it should be a full URL, not a
relative URI. Also, you should follow the location header with a call to
exit (or die).

header('Location: http://example.com/anotherpage.html');
exit;

--
Justin Koivisto, ZCE - ju****@koivi.com
http://koivi.com
Mar 23 '06 #5

P: n/a
universalbitmapper wrote:
Hi,
I'm trying a simple form.html that call a .html script that begins
with:

<?php
header("This is a test");
?>

When I click on the link, I get blank page.

I tried every combination of .html and .php as extensions, none works.

I checked the >Tools>Config>advanced menus in IE6, I can't find where
could be some filter to prevent the headers from displaying.

************************************************** ***********
I say without reservation, we ain't getting no hi-higher
It's a girl Mrs Walker it's a girl
************************************************** ***********


form.html can be normal HTML code as you would normally do. for the form
action, set it to a php file:

<form action="something.php" ...

If you use the post method, in something.php try this:

<?php
echo '<pre>';
print_r($_POST);
echo'</pre>';
?>

If you use the get method, change "_POST" to "_GET". All that does is
display the array structure of the submitted information. It should give
you some insight on how you will need to handle the data.

HTH

--
Justin Koivisto, ZCE - ju****@koivi.com
http://koivi.com
Mar 23 '06 #6

P: n/a
OK I see it's looking more complicated than it really is.
I just typed a 100 lines script from a manual: PHP MySQL Apache Web
Development.
Now, near the end there are these two lines:

$url = "location: showimage.php?id=" . $lastpicid;
header( $url );

Now at runtime I get the horrible:

"Header already sent" error

As you can see, it's the header() function I'm interested in, I thought
that if I went one step at a time, I'd find out why I get this error.
That's why I tried the little script in the original post, making sure
that the call to "header()" would be the first in the php script.
I haven't got the first clue why it's possible to use "header( $url );"
near the end of a script when the specs say it should be first.
But ok, I'll do my homework and look for typos, if I get somewhere I'll
keep you posted.
(But at the end of the day I'm disappointed that "header("this is a
test");" doesn't do anything. :-) )

Many thanks for your replies.

There only one thing more stubborn than a stubborn bug
It's a stubborn debugger ( circa Compuserve )

Mar 23 '06 #7

P: n/a
universalbitmapper wrote:
OK I see it's looking more complicated than it really is.
I just typed a 100 lines script from a manual: PHP MySQL Apache Web
Development.
Now, near the end there are these two lines:

$url = "location: showimage.php?id=" . $lastpicid;
header( $url );

Header() MUST be called before any output. have a single space before
the opening <? tag will break it. This is because the headers have to
be sent before the "meat" of the page. If there's a space, PHP thinks
you've done with the headers and want to start printing out a web page.
Check for spaces, html, anything before your first <? (or <?php) tag.

Also, I just can't resist correcting you for this, but your variable
name is wrong. $url isn't a url, you've included "Location:" in it. I
hate to be picky, but it will help to be strict when you start writing
BIG programs... Oh, casing your vars properly will help to, it's
subject to preference but I like camel case (each new "word" starts
with a capital). Erm, private cars also start with lower case, and
public with upper.

Try something like

$url = 'showimage.php?id'.$lastPicId;
header("Location: ".$url);
Good luck and enjoy yourself.

Mar 23 '06 #8

P: n/a
I didn't write this script, it comes from a manual.

That manual does not explain what particular job it uses header() in
this case for.

It's supposed to allow the user to load an image dynamically, then
display it.

It's very difficult to debug because there are 3 php pages involved and
inserting then querying from MySQL.

The bug could come from any place, like a space in the results from the
query.

But that's ok, I'll wake up some night a 3:27 and I'll shout "Eureka!"

Many thanks for your replies

****************************************
But a cheesy little amp
With a sign on the front
Said Fender Champ
- Frankie "What would you do?" Zappa
****************************************

Mar 24 '06 #9

P: n/a
Message-ID: <11**********************@v46g2000cwv.googlegroups .com> from
universalbitmapper contained the following:

The bug could come from any place, like a space in the results from the
query.


No it couldn't come from any place. PHP runs on the server, you can
have as much code as you like before header(), it's only generating
output if you either print or echo.

It is output you are looking for. Does your '<?php ' start right at the
top? A simple blank line (outside your php code) would cause output to
start.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Mar 24 '06 #10

P: n/a
You're right, I have added a few echo-es and print_r for debug purposes
to the original listing.
I'll remove them see what happens.
The header() call happens on line 62, the only "output" is an insert
in the database.

Still I'd like to have a debug tool that follows the .php navigation.

Many thanks for your reply.
*****************************
I'm going no-where
Somebody help me there
*****************************

Mar 25 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.