What is Website error?

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
davidhan
Forum Newbie
Posts: 2
Joined: Fri Sep 26, 2014 2:08 am
Location: news
Contact:

What is Website error?

Post by davidhan »

Hello every one.

I have an array and when I want to output or assign a value I simply did this:
$qOne[1] = $qOne[1] + 1;
fine I understand that it's the second element in my array. But when I run the php file, it works but gives me this error:
Undefined offset: 1
Meaning my 1 in my array $qOne[1]. First off, what is an undefined offset, and what is the problem with puting 1 in my [] ???? Thanks.

ads: website technology: tech new online sells products Best Tablet Android Have Price Under $200 and The Best Smartphone Display from amazon.
Last edited by davidhan on Thu Nov 27, 2014 12:29 am, edited 2 times in total.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: What is Website error?

Post by requinix »

Undefined offset means the $qOne array does not have an item with the key 1. When you try to use it in $qOne[1] + 1, PHP issues a warning because the value does not exist and wants to make sure you're aware of that.

Use print_r() or var_dump() to output the contents of $qOne and see if it what you expect. Then look at the code that defines $qOne to see why it's not creating that array element.
Post Reply