php - header ("Location: URL); Error -
this question has answer here:
- how fix “headers sent” error in php 11 answers
the insert works tested without header redirect. problem i'm using mysqli object oriented approach , still new it. when have header redirect in there tells me in browser
"warning: cannot modify header information - headers sent (output started @ /home/hawkwsco/public_html/admin/include/template/doc.inc.php:1) in /home/hawkwsco/public_html/admin/include/library/functions/process/process.inc.php on line 10"
my code below:
<?php require ($_server['document_root'].'/admin/include/config/config.inc.php'); $query = ("insert page(pa_id, pa_page, pa_page_info) values ('null', '{$_post['page']}', '{$_post['info']}')"); $mysqli->query($query); header("location: http://".$_server['server_name']."/admin/content.php"); exit; ?>
what doing wrong?
most file including has text in being output (even newline @ end of file enough) causing output start before header can sent. make sure includes not have ?> @ end avoid problem.
alternatively, can use output buffering (ob_start()) avoid output being sent until ready. ob_start() must called before output effective.
Comments
Post a Comment