problem with content loader

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Getran
Forum Commoner
Posts: 59
Joined: Wed Aug 11, 2004 7:58 am
Location: UK
Contact:

problem with content loader

Post by Getran »

i wrote this script and as u can probably see if loads content, and makes it so u can use page.php?p=bla. But i'm getting another undefined index error, this is the error:

Notice: Undefined index: content in *hidden*\test.php on line 2

this is the only contents of the file :

Code: Select all

<?php
$p = $_GET['p'];
if($p == "") {
$p = "test";
}
include("$p.inc");
?>
can somebody help me with this ? (sorry to have posted alot recently but i love the fast responses here :))
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

Try this:

Code: Select all

<?php
include($p.".inc");
?>
Getran
Forum Commoner
Posts: 59
Joined: Wed Aug 11, 2004 7:58 am
Location: UK
Contact:

Post by Getran »

i get the same error, cus it's not that causing the problem. Even tho i get the error it still includes the page...
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

That's not an error. That's PHP warning you of a vulnerability because you never defined an index in $_GET. Feel free to ignore that. Also, your PHP is set to display very strict notices, if that's a production server, that's very wierd. To get rid of that error, you can just put this line at the top of your code:

Code: Select all

<?php
$_GET['p'];
?>
That should make the notice go away. (Sorry, I misread the error message, and thought it wasn't including properly).
Getran
Forum Commoner
Posts: 59
Joined: Wed Aug 11, 2004 7:58 am
Location: UK
Contact:

Post by Getran »

it didn't make it go away :/ i just got the same message for on that line
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Re: problem with content loader

Post by scorphus »

Getran wrote:(...) Notice: Undefined index: content in *hidden*\test.php on line 2 (...)
In this case it complains because you're trying to access an invalid 'content' index from an array ($array['content']) in *hidden*\test.php on line 2. Open test.php, look for this line 2 and see what's wrong.

-- Scorphus.
Post Reply