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

How can I stop this error occurring pls?

Folks.

I have some PHP code on my site at

http://www.london-translations.co.uk/quick-quote.php

Which allow people to get quotes for translation work. When the form
is submitted control passes to …

http://www.london-translations.co.uk...te-results.php

And everything is fine. The problem is, people seem to be landing
directly on

http://www.london-translations.co.uk...te-results.php

When they do, errors of the following kind appear
Warning: Cannot modify header information - headers already sent by
(output started at \\nas06ent\domains\l\london-translations.co.uk\user\htdocs\quick-quote-results.php:2)
in \\nas06ent\domains\l\london-translations.co.uk\user\htdocs\quick-quote-results.php
on line 499

Warning: Cannot modify header information - headers already sent by
(output started at \\nas06ent\domains\l\london-translations.co.uk\user\htdocs\quick-quote-results.php:2)
in \\nas06ent\domains\l\london-translations.co.uk\user\htdocs\quick-quote-results.php
on line 500

Is there a way in PHP checking that people have come from
http://www.london-translations.co.uk/quick-quote.php without throwing
errors up .. .ideally I'd like them to be automatically sent to
http://www.london-translations.co.uk/quick-quote.php but a meaningful
message would be better than bombing out like now.

Thanks

Pete Bennett
Jul 17 '05 #1
8 1852
It should be possible to check HTTP_REFERER in the $_SERVER array and
redirect based on that. Can't think of the exact code off-hand, but,
something like this at the top of the script should work:

if($_SERVER["HTTP_REFERER"] != "your starting page"){
header("Location:your starting page");
}else{
the rest of the script

}
hth

C

Jul 17 '05 #2
On Mon, 04 Oct 2004 14:03:55 +0100, Chris <ch************@nez.oc.ku>
wrote:
It should be possible to check HTTP_REFERER in the $_SERVER array and
redirect based on that. Can't think of the exact code off-hand, but,
something like this at the top of the script should work:

if($_SERVER["HTTP_REFERER"] != "your starting page"){
header("Location:your starting page");
}else{
the rest of the script

}


Just reading the documentation for HTTP_REFERER and it might not be
the best method since some browsers allow it to be disabled or
modified.

Why not send some token data, probably in a hidden form field, from
the first page and check for its existance in the second page,
redirecting to the first page if it doesn't exist?

C

Jul 17 '05 #3
Pete Bennett wrote:
I have some PHP code on my site at

http://www.london-translations.co.uk/quick-quote.php

Which allow people to get quotes for translation work. When the form
is submitted control passes to …

http://www.london-translations.co.uk...te-results.php

And everything is fine. The problem is, people seem to be landing
directly on

http://www.london-translations.co.uk...te-results.php

When they do, errors of the following kind appear


Warning: Cannot modify header information - headers already sent by
(output started at
\\nas06ent\domains\l\london-translations.co.uk\user\htdocs\quick-quote-results.php:2) in
\\nas06ent\domains\l\london-translations.co.uk\user\htdocs\quick-quote-results.php on line 499

Warning: Cannot modify header information - headers already sent by
(output started at
\\nas06ent\domains\l\london-translations.co.uk\user\htdocs\quick-quote-results.php:2) in
\\nas06ent\domains\l\london-translations.co.uk\user\htdocs\quick-quote-results.php on line 500

Is there a way in PHP checking that people have come from
http://www.london-translations.co.uk/quick-quote.php without throwing
errors up .. .ideally I'd like them to be automatically sent to
http://www.london-translations.co.uk/quick-quote.php but a meaningful
message would be better than bombing out like now.


The reason for the errors is that you're trying to send a header to redirect
the user *after* you've already sent output to the browser.

eg you're doing something like this:

print "some output here";
header("Location:
http://www.london-translations.co.uk/quick-quote-results.php");

Because you already sent output with the "some output here" line you can't
then send a header to the browser. So you'll need to rearrange the logic on
the page a bit to ensure all your processing happens first, and all the
output second.

From the error messages you have received, it's telling you the output
started at line 2 in the file and that you've tried to add a header at
499/500.

A really quick and dirty solution to your problem is to add ob_start() to
the beginning of the file. This turns output buffering on which means
nothing will be sent to the browser until you flush the buffer, which won't
happen if you redirect to another page. However, it's best to fix your code
than do this.

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Jul 17 '05 #4
While the city slept, Pete Bennett (pm**@futureim.demon.co.uk) feverishly
typed...
Folks.

I have some PHP code on my site at

http://www.london-translations.co.uk/quick-quote.php

Which allow people to get quotes for translation work

[...]

As an aside, you state that the "quick quote" isn't binding. IANAL, but I
think if you start offering "quotes" and then say they aren't binding, you
could get into tricky water. You would be better offering an "estimate",
which has a different legal status. Like I say, IANAL.

Cheers,
Nige

--
Nigel Moss
http://www.nigenet.org.uk
Mail address not valid. ni***@DOG.nigenet.org.uk, take the DOG. out!
In the land of the blind, the one-eyed man is very, very busy!
Jul 17 '05 #5
Folks,

Thanks for all your help so far however I am still baffled. As a test,
I altered my code to look like this...

1. <html>
2. <?
3. header("Location: ../quick-quote-down-wc.html");

In other words, what ever happens later, people should be sent to the
new page right? Unfortunately I still get

Warning: Cannot modify header information - headers already sent by
(output started at \\nas06ent\domains\l\london-translations.co.uk\user\htdocs\quick-quote-results.php:2)
in \\nas06ent\domains\l\london-translations.co.uk\user\htdocs\quick-quote-results.php
on line 3

Warning: mail(): SMTP server response: 554 Error: no valid recipients
in \\nas06ent\domains\l\london-translations.co.uk\user\htdocs\quick-quote-results.php
on line 793

Surely, the rest of the code should even be read by the computer never
mind be able to kick out errors as people should be sent straight to
the quick-quote-down-wc.html page?

Am I missing something please?

Pete Bennett
Jul 17 '05 #6
You have not read the manual properly. You cannot send headers after
generating any other output, so drop the <html> line. You should also use
exit() immediately after header().

--
Tony Marston

http://www.tonymarston.net
"Pete Bennett" <pm**@futureim.demon.co.uk> wrote in message
news:e7**************************@posting.google.c om...
Folks,

Thanks for all your help so far however I am still baffled. As a test,
I altered my code to look like this...

1. <html>
2. <?
3. header("Location: ../quick-quote-down-wc.html");

In other words, what ever happens later, people should be sent to the
new page right? Unfortunately I still get

Warning: Cannot modify header information - headers already sent by
(output started at
\\nas06ent\domains\l\london-translations.co.uk\user\htdocs\quick-quote-results.php:2)
in
\\nas06ent\domains\l\london-translations.co.uk\user\htdocs\quick-quote-results.php
on line 3

Warning: mail(): SMTP server response: 554 Error: no valid recipients
in
\\nas06ent\domains\l\london-translations.co.uk\user\htdocs\quick-quote-results.php
on line 793

Surely, the rest of the code should even be read by the computer never
mind be able to kick out errors as people should be sent straight to
the quick-quote-down-wc.html page?

Am I missing something please?

Pete Bennett

Jul 17 '05 #7
Pete Bennett wrote:
1. <html>
2. <?
3. header("Location: ../quick-quote-down-wc.html");
Two errors and one bad line.

1. You're having output in line 1 (<html>) before you try to write the
header. This won't work.
2. You're using short tags. <?php would be better and will run anywhere.
3. You're using an invalid location. The Location-header needs an
absolute URI. For details have a look at the manual at
http://www.php.net/header.
Am I missing something please?


Yes, you are. ;-)

Regards,
Matthias
Jul 17 '05 #8
Folks,

All sorted now - thanks for all your help.
Jul 17 '05 #9

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

Similar topics

1
by: Attila.Rajmund.Nohl | last post by:
Hello! I'm using KAI C++ Compiler (KCC) Version 4.0d on Sparc Solaris 8 with Sun WorkShop 6 update 2 backend (KCC compiles C++ code to C than uses the Sun compiler to produce machine...
0
by: AA | last post by:
This mail is regarding a trouble I'm facing with SQL Server 2000. I'm working with ASP .NET V 1.1 and SQL Server 2000. I have a reporting module that generates XML reports from the SQL Server 2000...
9
by: Robert Wing | last post by:
I support an MS Access application in which errors are trapped using the On Error statement. Just recently, the users of this system have experienced run-time error number 3021 on a random basis. ...
1
by: intl04 | last post by:
I am getting strange print-related error messages when trying to create (not print!) reports. For example, when I click 'new' to create a report then choose 'design view', I get an error message...
10
by: robert d via AccessMonster.com | last post by:
I have a global error handler that up until today has been working flawlessly. Let me first provide the relevant code **************************************************************** On Error...
5
by: Jon Davis | last post by:
I'm hosting a .NET console application in a .NET Windows Service using System.Diagnostics.Process. How do I block the debugger dialogue from appearing? Thanks, Jon
3
by: cj | last post by:
This program is used to send files to an ftp server at 2:00am each day. At the very top of my program I dim a new instance of a com FTP control. I have a processing sub which calls a login function...
4
by: sudheer786 | last post by:
A purify error while doing build is setup -------------------------------------------------------------------------------- Hi all, I was facing a strange error while trying to run my labeled...
3
by: sophistiKate | last post by:
I have one user who has spontaneously begun getting the run-time error 3435, "Cannot delete spreadsheet cells" in Access 2002. (The is an Access error and not an Excel error, as evidenced by the...
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
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
0
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

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.