Header ("location (...) ");

hy!

I have problem with the function header. I think is because the php version, because I am testing in home server by using php 4.3, but when i upload for the server that are using php 4.0.6 the headers don’t work :frowning:

header("Location:index.php?accao=login_error");

Anda the error:

Warning: Cannot add header information - headers already sent by (output started at /var/www/html/apie/klog/admin/teste.php:8) in /var/www/html/apie/klog/admin/teste.php on line 9

Help me please :thumb:

I just have solution by using javascript like


<SCRIPT>window.location=\"editar.php produto=$produto\";</SCRIPT>

thks lol

hey, if you see this could you post the code you are using anyway? Just so we can figure out why it wasn’t working for future reference?

Source

print (“Error”);
header(“Location:index.php?accao=login_error”);

The conclusion for this problem is that in version 4.0.6, if we have a printf before a header, it get error, but in others versions not…

What i did, was clear the printf’s before headears and it works good… maybe isn’t that the real problem but it works without print :stuck_out_tongue:

might be a problem with that version yea.

Did you have any HTML placed before the header()? cuz yo ucan’t do that.

also, for the print function, there is no need for the ()

just type


print "Error";

hmm… i always use print with ()…but ok :P…and i don’t have html before header…

look, i have other problem, i have some sites working with php 4.06 but now i want upgrade de php version in server, but i have the problem with register_globals, if i ugrade to the last version, that sites that are working with 4.0.6, will brooke because the register globals…and it’s really boring to put $HTTP_GET_VARS[]; / $HTTP_POST_VARS[]; etc… in all old site…Do u know any solution for this??

danka :smiley:

well with the newer version you can put $_POST[] and $_GET[] instead of $HTTP_GET_VARS[]

or you can just turn global variables on…

Jubba, thks :stuck_out_tongue: