473,386 Members | 1,710 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,386 software developers and data experts.

404 header

GT
If I write a script like so:

<?php
header("HTTP/1.x 404 Not Found");
?>

and run it through IE or FF why don't I get the browser's page not
found message? I can see the header on liveheaders in FF but I don't get
the 404 I expect in the browser.

The whole script is to deliver rescaled jpegs, but I want a 404 if the
parameters are wrong, or it can't open the file etc..

Any help very much appreciated.

--
GT
Dec 27 '06 #1
4 3793

GT wrote:
If I write a script like so:

<?php
header("HTTP/1.x 404 Not Found");
?>

and run it through IE or FF why don't I get the browser's page not
found message? I can see the header on liveheaders in FF but I don't get
the 404 I expect in the browser.
The browser doesn't create the error message, the server does.
Usually, the default httpd error generated by apache or IIS
You've essentially created a custom 404 error page.

It's up to you to say "Page not found" or whatever.

perhaps you actually want a 405 or 406?
"Method Not Allowed" or "Not Acceptable"?

Dec 27 '06 #2
GT
BKDotCom wrote:
GT wrote:
>If I write a script like so:

<?php
header("HTTP/1.x 404 Not Found");
?>

and run it through IE or FF why don't I get the browser's page not
found message? I can see the header on liveheaders in FF but I don't get
the 404 I expect in the browser.

The browser doesn't create the error message, the server does.
Usually, the default httpd error generated by apache or IIS
You've essentially created a custom 404 error page.

It's up to you to say "Page not found" or whatever.

perhaps you actually want a 405 or 406?
"Method Not Allowed" or "Not Acceptable"?
Thanks,

So (if I understand correctly) the reason I don't get any output would
be because I haven't set up the Apache ErrorDocument to tell the server
what to serve in the case of these errors?

--
GT
Dec 27 '06 #3

GT wrote:
Thanks,

So (if I understand correctly) the reason I don't get any output would
be because I haven't set up the Apache ErrorDocument to tell the server
what to serve in the case of these errors?
The reason you don't get any output is because you didn't output
anything!
You simply sent a header. At least with your example.
try

<?php
header('HTTP/1.x 404 Not Found');
echo 'Page Not Found!';
?>

Dec 28 '06 #4
GT
BKDotCom wrote:
GT wrote:
>Thanks,

The reason you don't get any output is because you didn't output
anything!
You simply sent a header. At least with your example.
try

<?php
header('HTTP/1.x 404 Not Found');
echo 'Page Not Found!';
?>
I've been struggling with this! I think I was getting confused by the IE
404 message, which was sometimes appearing when I sent the header, and
sometimes not. That seems to be more reliable today - just a cacheing
issue perhaps? Seems good enough now though. Thanks for the help.
Dec 28 '06 #5

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

Similar topics

6
by: John | last post by:
Hi. I am having a few header problems at the moment with a login page. I don't have my headers at the top of the page where I've learned I need to have them. However, I also know I'm supposed...
11
by: Steven T. Hatton | last post by:
In the past there have been lengthy discussiions regarding the role of header files in C++. People have been very adamat about header files serving as in interface to the implementation. I do...
60
by: Derrick Coetzee | last post by:
It seems like, in every C source file I've ever seen, there has been a very definite include order, as follows: - include system headers - include application headers - include the header...
18
by: John Smith | last post by:
Hi all What does the group think of the practise of including one header file from inside another? I have some legacy code where this has been done, and it creates a dependency on a module...
6
by: Jason Collins | last post by:
There seems to be an inconsistency (bug?) in the way the Set-Cookie header is handled by the WebHeaderCollection. That is, the values of Set-Cookie, when an Expires is specified, contain the ","...
0
by: Dean Hallman | last post by:
Hello, I am developing a BHO that should add a custom HTTP header on a specific domain only. Don't want the header globally, otherwise I could just add a registry key. So, on...
4
by: Joseph Geretz | last post by:
We use a Soap Header to pass a token class (m_Token) back and forth with authenticated session information. Given the following implementation for our Logout method, I vastly prefer to simply code...
1
by: Shalako | last post by:
I check my error log and see these entries: malformed header from script. Bad header= Missing gauge reports are ind: padata.pl /perl/pema/padata.pl did not send an HTTP header malformed...
5
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
I have a sub in vb.net that adds extra headers to a gridview and it works very well. however, i tried to translate it to c# and i'm getting the header inserting itself over the first datarows and...
30
by: xiao | last post by:
HI~ EVERY ONE~ I have a small program here, when I tried to compile it , it always reminds that arrary.c: In function `main': arrary.c:39: error: `header' undeclared (first use in this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.