PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
i'm writing a redirect.php page for a CMS. the admin user makes whatever changes they want to certain information in the database, then clicks submit. they are taken to redirect.php which handles all the sql commands depending on what the admin wanted to change. and then they are redirected to another page, depending on the types of changes they made, as well... the header is not working. here's the error:
Warning: Cannot modify header information - headers already sent by (output started at /../../../admin/redirect.php) in /../../../admin/redirect.php on line 41
you can't send headers AFTER you've sent output (body). That is completely backwords. once you've echoed or printed ANYTHING to the screen, you can no longer modify header information.
If you need to display a message to the user while the page is redirecting, use a meta redirect... otherwise, just send the header and DONT output the message.
i'm not sure why my sql commands aren't being executed on this redirect.php... anybody see anything wrong with the code? it's not bringing me any errors...
<?php
function http_redirect($location)
{
if(!headers_sent())
{
header('Location: ' . $location);
}
else
{
/**
* Maybe put a meta redirect or echo out a link to click on here... or maybe
* even a javascript redirect... or just exit with a message saying "error - headers already sent"
*/
}
exit;
}
?>
<?php
function http_redirect($location)
{
if(!headers_sent())
{
header('Location: ' . $location);
}
else
{
/**
* Maybe put a meta redirect or echo out a link to click on here... or maybe
* even a javascript redirect... or just exit with a message saying "error - headers already sent"
*/
}
exit;
}
?>
the headers are working fine, ninja. they're redirecting to the exact place they're supposed to. but the whole purpose of this redirect.php page is so that i can execute some SQL commands (replacing data in the SQL table), and the page they are directed to will display the new results. what's the issue? is there something wrong with my SQL command?
btw, TOOL is the best band in the history of the world.
i figured out the problem... i was missing a ')' in a couple of places. but now it gives me a parse error on line 37... and i don't see what i'm doin wrong...
boo_lolly wrote:TOOL is the best band in the history of the world.
w00t! I'm listening to <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> right now! He's just about to say "And if when I say I might fade like a sigh if I stayeeyay! You minimize my movement anywaaaaayyy! I must persuade you another waaaaaaaaaaaaaaaaaaayyyyyyyy!"
pushin shuvin pushin me. THERE'S NO LOVE IN FEEEEEEEEEEEEEEEAAAAAAAAAAAAAAAAAAR!!!!!!!!
hey volka, you're right. what i meant to do was UPDATE. not INSERT. good call bud. so how would i do all that insert stuff as an UPDATE command?? this is what i've got so far... but it still gives me the same error...
boo_lolly wrote:pushin shuvin pushin me. THERE'S NO LOVE IN FEEEEEEEEEEEEEEEAAAAAAAAAAAAAAAAAAR!!!!!!!!
hey volka, you're right. what i meant to do was UPDATE. not INSERT. good call bud. so how would i do all that insert stuff as an UPDATE command?? this is what i've got so far... but it still gives me the same error...
hey everyone, thanks for all the great advice!! it's helped a lot. i've got an exit; after my redirects. the SQL error now is just a syntax error, which is better than before. but i've got ANOTHER problem... for some odd reason, my $_POST[''] commands aren't working. it's weird, they're just not being sent to the next page... i have no idea why. they're being sent the same way all my data has been sent to other pages... but it just won't work for this one... and the worst part about it is that the page that the information is coming from is an admin editing page... when the admin clicks 'SAVE' it takes them to 'redirect.php' which runs all the SQL queries. but the new editions aren't being posted either... it's just taking the same information from before the editions were made to the data....
the first thing i need to do is figure out the syntax error... You have an error in your SQL syntax near 'WHERE uID = '' SET brideFname = '', brideLname = '', groomFname = '' groomLname ' at line 1