473,325 Members | 2,608 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

What is an undefined offset? An undefined index?

I just switched error_reporting to ALL so I could debug my site. I got
a huge page full of errors. One of the most common was that in my
arrays I'm using undefined offsets and indexes. These still work fine,
but with error reporting at all they are marked as errors. Why? What
am I doing wrong?

www.monkeyclaus.org
Jul 16 '05 #1
1 108792
In article <da**************************@posting.google.com >,
lk******@geocities.com (lawrence) wrote:
I just switched error_reporting to ALL so I could debug my site. I got
a huge page full of errors. One of the most common was that in my
arrays I'm using undefined offsets and indexes. These still work fine,
but with error reporting at all they are marked as errors. Why? What
am I doing wrong?


It means you're referring to an array key that doesn't exist. "Offset"
refers to the integer key of a numeric array, and "index" refers to the
string key of an associative array.

$s_arr=array("apple", "banana");
print $s_arr[2]; //undefined offset

$a_arr=array("fruit"=>"apple", "meat"=>"beef");
print $a_arr['produce']; //undefined index

--
CC
Jul 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Steven | last post by:
Hi All, I am moving some php code from a Linux machine to a Windows 2000 machine with the code belowe I get the following error : Notice: Undefined offset: 1 in c:\inetpub\wwwroot\test.php on...
1
by: google | last post by:
Hello, I'm having major problems trying to get my head round this problem. I'm trying to generate an error free script, however, I still cannot sort out this loop. I get a "Notice:...
4
by: Richard Lawrence | last post by:
Hi there, I'm having a problem with PHP which I'm not sure how to best solve. Here is the code: $fp = fopen("comments.txt", "r"); while(!feof($fp)) { $line = fgets($fp, 1024); list($key,...
6
by: nicy12 | last post by:
Hi! my name is Peter. iam working on the php platform. while trying to run and compile a program i get the undefined offset error iam nto much familiar with this error . Please help me . Thanks in...
9
by: simple12 | last post by:
Hello I have a script which have the facility of entering any code to some part of a webpage. I have some problems with it. When i put some code in the script then their is no error shown. When i...
6
by: raydiamond4u | last post by:
Hello. My name is Raymond. My code is generating the following error: Notice: Undefined offset: 2 in C:\wamp\www\imagegallery\supportfile\include\config.php on line 25 How do i correct the error?...
1
by: atang | last post by:
Hi, I found the code here, it's excately what i am looking for, ie8 give this error "Notice: Undefined offset: 49 in.." which is this line "if ($num_of_chars==$required)", i'm a newbie, i don't know...
6
by: tbebest | last post by:
Hi , i have a form and it has A problem: i upload my 3 image and it uploaded in definded path but in insert in db filed there are empty: Notice: Undefined offset: 0 in C:\wamp\www Notice:...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.