Please Help...problem-undefined index

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
djamorpheus
Forum Newbie
Posts: 4
Joined: Mon Jun 16, 2003 10:35 pm

Please Help...problem-undefined index

Post 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
bjg
Forum Newbie
Posts: 15
Joined: Tue Jun 10, 2003 9:42 am
Location: .au

Post by bjg »

Paste your code on line 25.
User avatar
trollll
Forum Contributor
Posts: 181
Joined: Tue Jun 10, 2003 11:56 pm
Location: Round Rock, TX
Contact:

Post 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?
djamorpheus
Forum Newbie
Posts: 4
Joined: Mon Jun 16, 2003 10:35 pm

Post by djamorpheus »

sorry but i dont get what you just said...
User avatar
trollll
Forum Contributor
Posts: 181
Joined: Tue Jun 10, 2003 11:56 pm
Location: Round Rock, TX
Contact:

Post 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! :)
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

And as is often the case, if you don't post your code we can't offer you very specific help.

Mac
djamorpheus
Forum Newbie
Posts: 4
Joined: Mon Jun 16, 2003 10:35 pm

Post 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;
}
?>
nasr
Forum Newbie
Posts: 13
Joined: Wed Jun 25, 2003 9:29 pm
Location: Cali

Post 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:
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post 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.
djamorpheus
Forum Newbie
Posts: 4
Joined: Mon Jun 16, 2003 10:35 pm

Post by djamorpheus »

hmm ill try that thanx
Post Reply