truenitin Posted July 4, 2006 Share Posted July 4, 2006 Notice: Undefined variable: p in c:\program files\easyphp1-8\www\index.php on line 11Notice: Undefined variable: p in c:\program files\easyphp1-8\www\index.php on line 19Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\index.php:11) in c:\program files\easyphp1-8\www\index.php on line 23I am getting this error when i run the following code.<?phpif (isset($_GET['page']) and $_GET['page'] != "") { $p = $_GET['page']; }if (strpos($p,"..")) { die("Bad page request");}if (!$p) $p = "main";$content_file=$_SERVER["DOCUMENT_ROOT"]."/".$p.".php";if (!file_exists($content_file)) { header("Location: {$_SERVER["PHP_SELF"]}"); exit();}$title = ($p) ? "$p - My Site!" : "Main page - My Site!";include("header.php");include($content_file);include("footer.php");?>i get this error when i use session_register also.A possible solution?Nitin Link to comment https://forums.phpfreaks.com/topic/13642-headers-already-sent/ Share on other sites More sharing options...
zawadi Posted July 4, 2006 Share Posted July 4, 2006 you need to define 'p' at the start of your script, you also need to make sure that you dont output ANYTHING till you get to the 'header()' including empty lines. Link to comment https://forums.phpfreaks.com/topic/13642-headers-already-sent/#findComment-52900 Share on other sites More sharing options...
wildteen88 Posted July 4, 2006 Share Posted July 4, 2006 Try this instead:[code=php:0]if (isset($_GET['page']) and $_GET['page'] != ""){ $p = $_GET['page'];}else{ $p = "main";}if (strpos($p, "..")){ die("Bad page request");}$content_file = $_SERVER["DOCUMENT_ROOT"] . "/" . $p . ".php";if (!file_exists($content_file)){ header("Location: {$_SERVER['PHP_SELF']}"); exit();}$title = ($p) ? "$p - My Site!" : "Main page - My Site!";include("header.php");include($content_file);include("footer.php");[/code] Link to comment https://forums.phpfreaks.com/topic/13642-headers-already-sent/#findComment-52901 Share on other sites More sharing options...
XoNoX Posted July 4, 2006 Share Posted July 4, 2006 I got the same problemI resolved my problem just by open my database by "localhost" no IP Link to comment https://forums.phpfreaks.com/topic/13642-headers-already-sent/#findComment-52920 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.