Hi guys.
I'm storing my web pages in a mysql database and use sql query's to fetch and load the pages. My site effectively consists of 1 page called home.php.
I have query that says
if (isset($_GET['p_name'])){
$getpage = mysql_real_escape_string($_GET['p_name']);
$query = "select * from pages where p_name = '$getpage' ORDER by id DESC limit 1";
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_array($result)){
eval('?>' . $row['p_content'] . '<?php ');}}?>
Well my problem is that I use the header() function to redirect users to other pages for numerous reasons like... after a login, after a database insertion etc.
Well each page that is pulled from the database that uses the header() gives me an error that says
Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\ in C:\AppServ\ : eval()'d code on line 49
Here is a page that pulls from the database (home.php?p_name=logout)
I've been using the meta refresh tag to redirect pages, but it's not as effective and actually shows the page for a split second before if refreshes, even when set on 0 seconds to refresh.
// Unset all of the session variables.
$_SESSION = array();
// Finally, destroy the session.
session_destroy();
echo"<META http-equiv='refresh' content='0;URL=home.php'/>";
I would like to use
header("Location: home.php"); but I get the error.
Any help would be greatly appreciated.
From what I've been reading I think it has something to do with the home page has already sent headers and when I use a query to change the content of the home page and the new content tries to send another header giving me the error. I'm not sure if this is it but maybe.
Also I keep reading to make sure I don't send white spaces before the header, but I don't know what they mean by empty or white spaces being sent causing errors. How do I check? Where do I look for the white spaces?
I'm storing my web pages in a mysql database and use sql query's to fetch and load the pages. My site effectively consists of 1 page called home.php.
I have query that says
if (isset($_GET['p_name'])){
$getpage = mysql_real_escape_string($_GET['p_name']);
$query = "select * from pages where p_name = '$getpage' ORDER by id DESC limit 1";
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_array($result)){
eval('?>' . $row['p_content'] . '<?php ');}}?>
Well my problem is that I use the header() function to redirect users to other pages for numerous reasons like... after a login, after a database insertion etc.
Well each page that is pulled from the database that uses the header() gives me an error that says
Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\ in C:\AppServ\ : eval()'d code on line 49
Here is a page that pulls from the database (home.php?p_name=logout)
I've been using the meta refresh tag to redirect pages, but it's not as effective and actually shows the page for a split second before if refreshes, even when set on 0 seconds to refresh.
// Unset all of the session variables.
$_SESSION = array();
// Finally, destroy the session.
session_destroy();
echo"<META http-equiv='refresh' content='0;URL=home.php'/>";
I would like to use
header("Location: home.php"); but I get the error.
Any help would be greatly appreciated.
From what I've been reading I think it has something to do with the home page has already sent headers and when I use a query to change the content of the home page and the new content tries to send another header giving me the error. I'm not sure if this is it but maybe.
Also I keep reading to make sure I don't send white spaces before the header, but I don't know what they mean by empty or white spaces being sent causing errors. How do I check? Where do I look for the white spaces?