Jump to content


Photo

Headers already sent


  • Please log in to reply
3 replies to this topic

Poll: headers already sent (1 member(s) have cast votes)

headers already sent

  1. 1 (1 votes [100.00%])

    Percentage of vote: 100.00%

  2. 2 (0 votes [0.00%])

    Percentage of vote: 0.00%

Vote Guests cannot vote

#1 truenitin

truenitin
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 04 July 2006 - 02:33 PM

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

#2 zawadi

zawadi
  • Members
  • PipPip
  • Member
  • 25 posts
  • LocationChippenham UK

Posted 04 July 2006 - 02:39 PM

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.
That's the beauty of asymmetric warfare. You don't need a lot of money, or an army of people. You can do it from the comfort of your living room, with a beer in your hand.

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 04 July 2006 - 02:39 PM

Try this instead:
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");


#4 XoNoX

XoNoX
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 04 July 2006 - 03:26 PM

I got the same problem
I resolved my problem just by open my database by "localhost" no IP




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users