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.
What is Website error?
Moderator: General Moderators
What is Website error?
Last edited by davidhan on Thu Nov 27, 2014 12:29 am, edited 2 times in total.
web chuyên lắp mạng fpt thuận an và lắp mạng fpt dĩ an và lắp mạng fpt tân uyên và lắp mạng fpt thủ dầu một cho khách hàng.
Re: What is Website error?
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.
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.