Undefined offset

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
Todlerone
Forum Commoner
Posts: 96
Joined: Sun Oct 28, 2007 10:20 pm
Location: Hamilton, Ontario, Canada

Undefined offset

Post by Todlerone »

Hello everyone and TGIF if it fits. Thank-you in advance for any help/suggestions. I've created a function that takes in passed variables and is supposed to populate an array for me. I have echoed all my variables and they do exist. My problem is when I try to assign a value to the array I get "Undefined offset: 7".

Code: Select all

$standings[$V][2]+=1;
The $V variable is correctly set (in this case it is 7).

CHEERS
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Undefined offset

Post by requinix »

Before that statement do a

Code: Select all

print_r($standings);
Whatever you may say, $standings[7] doesn't exist.
Todlerone
Forum Commoner
Posts: 96
Joined: Sun Oct 28, 2007 10:20 pm
Location: Hamilton, Ontario, Canada

Re: Undefined offset

Post by Todlerone »

tasairis wrote:Before that statement do a

Code: Select all

print_r($standings);
Whatever you may say, $standings[7] doesn't exist.

It says Array() and that's all..
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Undefined offset

Post by requinix »

Todlerone wrote:It says Array() and that's all..
Then it's empty. There's nothing in it. Means there's a mistake earlier in the code.

Does this code happen to be inside of a function? Where is $standings coming from?
Todlerone
Forum Commoner
Posts: 96
Joined: Sun Oct 28, 2007 10:20 pm
Location: Hamilton, Ontario, Canada

Re: Undefined offset

Post by Todlerone »

Yes it is inside a function.
Post Reply