Page 1 of 1

Please Help...problem-undefined index

Posted: Mon Jun 16, 2003 10:35 pm
by djamorpheus
i dont understand i always get this message on my website http://www.djamorpheus.com/main.php

message: Notice: Undefined index: page in D:\webspace\resadmin\be122f7\djamorpheus.com\www\main.php on line 25


Please help me

Posted: Mon Jun 16, 2003 11:33 pm
by bjg
Paste your code on line 25.

Posted: Mon Jun 16, 2003 11:37 pm
by trollll
Assuming that you keep your updates somewhere outside of the php file, load them into an array and run through the array writing the value into a template I would first guess that your loop tries to access an array index that doesn't exist.

If not, can you post some of the code you use to run through and write the updates out?

Posted: Tue Jun 17, 2003 9:25 pm
by djamorpheus
sorry but i dont get what you just said...

Posted: Tue Jun 17, 2003 11:19 pm
by trollll
You may want to check out php.net's documentation on arrays to brush up a bit.

Usually with an error that says something about an "undefined index" means that you have an array with a certain number of things stored in it and then it tried to get a value bigger than that number. For example:

Code: Select all

$my_array = Array('one','two','three');
echo $my_arrayї2];
would work, while

Code: Select all

$my_array = Array('one','two','three');
echo $my_arrayї3];
should give you an undefined index error, as the index (3) has not gotten defined yet.

hope that helps! :)

Posted: Wed Jun 18, 2003 4:17 am
by twigletmac
And as is often the case, if you don't post your code we can't offer you very specific help.

Mac

Posted: Wed Jun 25, 2003 11:03 pm
by djamorpheus
here is the code

<?php
ini_set("include_path", "C:\phpdev\www");
switch ($_GET["page"] ) {
case "pics":
include('pictures.php');
break;
case "contact":
include('contact.php');
break;
case "links":
include('links.php');
break;
case "mypics":
include('me.php');
break;
case "art":
include('art.php');
break;
case "about":
include('aboutme.php');
break;
case NULL:
include('home.php');
break;
default:
include('error.php');
break;
}
?>

Posted: Wed Jun 25, 2003 11:08 pm
by nasr
This is what u did wrong.

Code: Select all

<?php
switch ($_GET["page"] ) { 

?>
it should be like this

Code: Select all

<?php
switch ($_GET['page'] ) { 

?>
correct me if im wrong.


Nas :roll:

Posted: Thu Jun 26, 2003 2:34 am
by []InTeR[]
Why dont you do something like?
include($_GET["page"].".php");

And use a if(isset($_GET["page"])) before using it.

The error is from the "page", the array _GET exists, but the "page" doesn't.

Posted: Fri Jun 27, 2003 12:04 am
by djamorpheus
hmm ill try that thanx