Jump to content

Archived

This topic is now archived and is closed to further replies.

truenitin

Headers already sent

headers already sent  

1 member has voted

  1. 1. headers already sent

    • 1
      1
    • 2
      0


Recommended Posts

Notice: Undefined variable: p in c:\program files\easyphp1-8\www\index.php on line 11

Notice: Undefined variable: p in c:\program files\easyphp1-8\www\index.php on line 19

Warning: 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 23

I am getting this error when i run the following code.

<?php

if (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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
I got the same problem
I resolved my problem just by open my database by "localhost" no IP

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.