Page 1 of 1

What is Website error?

Posted: Fri Sep 26, 2014 2:18 am
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.

Re: What is Website error?

Posted: Fri Sep 26, 2014 4:22 am
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.