FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Header("Location: PROBLEM");





markgil
hi to all, i have a problem with code.

this

$result = $db->sql_query("UPDATE ".$prefix."_gax_wbox SET......'");
Header("Location: ".$adminfile.".php?adminload=$modulename&plugin=Proyectos");
}

it works well

this

if($choice == "No"){
Header("Location: ".$adminfile.".php?adminload=$modulename&plugin=Admin_Mensajes");
}

it works bad

this says brownser:

Warning: Cannot add header information - headers already sent by (output started at d:\easyphp\www\zentri\core.php:662) in d:\easyphp\www\zentri\plugins\admin\GaxBox\plugins\Admin_Mensajes\index.php on line 39

What is the problem??
somebody can help me?
thanks
snowboardalliance
You know it has to be before ANYTHING is outputted. Also, if you use both of those, you should make sure that the first one is not used when the second one is.
WickedGravity
This issue is not a General CHat topic. It is a scripting question. Thusly, it should be in the Scripting forum,

Moved
phponly
Actully u r sending header after sending body elements
i far i know in php it is not allowed
so u have to check that carefully in source code also check this out

http://www.oreilly.com/catalog/phpckbk/chapter/ch08.pdf
mathiaus
as everyone else has already said the header tag can only be used before anything is shown such as text etc but not processing.
As the time cannot be set before the redirection there really is very little point in displaying anything so unless your displaying errors and havent excluded it theres no point for anything apart from the processing and the header command.

If however you do want other info displayed or want a certain amount of time before the redirection takes place you should consider using a meta version

Code:
<META HTTP-EQUIV="Refresh" CONTENT="5; URL=http://site.com/index.html">

Here the content controls first the time and then the url. To be html valid it should be in the head section of your site but will work if no head or body tags are used, before or after anything is displayed.

you can use that or post your code up and we'll see if it can sorted Smile
izcool
I wouldn't recommend Meta Refresh because there is an option for people to turn it off in their browser.

- Mike.
vspec
use gzip on your page, which stores the output of the script, runs the headers, then shows the output so that error doesn't show. normally you have to output headers before anything else is outputted to the screen.
buileminh
markgil wrote:
hi to all, i have a problem with code.

this

$result = $db->sql_query("UPDATE ".$prefix."_gax_wbox SET......'");
Header("Location: ".$adminfile.".php?adminload=$modulename&plugin=Proyectos");
}

it works well

this

if($choice == "No"){
Header("Location: ".$adminfile.".php?adminload=$modulename&plugin=Admin_Mensajes");
}

it works bad

this says brownser:

Warning: Cannot add header information - headers already sent by (output started at d:\easyphp\www\zentri\core.php:662) in d:\easyphp\www\zentri\plugins\admin\GaxBox\plugins\Admin_Mensajes\index.php on line 39

What is the problem??
somebody can help me?
thanks

You can check in file core.php and index.php if there is one of following:
- blank characters: space, line break, ...
- send cookie before call function header() ???
kv
This problem occurs when you have output some data before a Header(Location). Looks like in your case, the output was done in file

d:\easyphp\www\zentri\core.php

Line number 662.

see that you do not have output any data before header method. It should solve the problem.
Lacoste
One more solution for redirect using html+javascript

Code:

<form name="auto" action="dest_url"></form>
<script>
document.auto.submit()
</script>


you can even pass some POST-parameters in that way.

Good luck.
Related topics
managing a bilingual site
SPIP
redirect(append_sid()); - need help !
PHP script has MSQL access denied
How to write redirection sentence in PHP?
php page-refresh/redirect/boot help needed please
Header phase problem
how to prevent double post when user klik F5 *Refresh* ?
Sessions
Header redirect problem
url rewrite
Javascript and Dynamic Select Boxes
Authentication Module
Simple php & mysql script
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.