homepage Welcome to WebmasterWorld Guest from 54.161.133.166
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Undefined offset: 1 - what does it mean?
royp2000




msg:1260513
 11:21 pm on Nov 25, 2003 (gmt 0)

Hello,

I'm getting the following error when running one of my php scripts:

Undefined offset: 1 in /ftp/virt/techno/classifieds/advertisement.php on line 530

I checked the folowing line (530) and all I had in it was:

$curent_cat_id=$fourth_id_cut[1];

What can cause this error and what does it mean?

Thanks in advance,

Roy

 

Distel




msg:1260514
 11:40 pm on Nov 25, 2003 (gmt 0)

I found something regarding these errors, which seem to be related to calendars. They suggested a CVS update, whatever the heck that is. ;)

trajan




msg:1260515
 11:56 pm on Nov 25, 2003 (gmt 0)

are you sure that your array-field "$fourth_id_cut[1]" is really set?

in my opinion this notice means that the array value of $fourth_id_cut at key 1 is undefined...

jatar_k




msg:1260516
 12:04 am on Nov 26, 2003 (gmt 0)

Welcome to WebmasterWorld trajan,

I was thinking exactly that as well.

royp2000




msg:1260517
 12:46 am on Nov 26, 2003 (gmt 0)

Yea, I'm sure it is set:

529: $fourth_id_cut=explode("=",$third_id_cut);
530:$curent_cat_id=$fourth_id_cut[1];

Any other ideas?

Thanks,

Roy

coopster




msg:1260518
 12:58 am on Nov 26, 2003 (gmt 0)

Try this to make sure:

529: $fourth_id_cut=explode("=",$third_id_cut);
529 1/2: print '<pre>'; print_r($fourth_id_cut); exit('</pre>');
530:$curent_cat_id=$fourth_id_cut[1];

globay




msg:1260519
 1:05 am on Nov 26, 2003 (gmt 0)

are you sure, that there is always a something after "=" in $third_id_cut? If $third_id_cut does not contain =, $fourth_id_cut[1] won't be set.
in $fourth_id_cut=explode("=",$third_id_cut);

And yes, Undefined offset: 1 indicates that $fourth_id_cut[1] is not set

royp2000




msg:1260520
 9:56 am on Nov 26, 2003 (gmt 0)

coopster: I can't enter this line, it causes errors.

globay: Now that you've mentioned it, maybe there is one chance that there is nothing after the "=".

Hmmm... I guess that if I'll enter the following line, it should sove it, isn't it:

$fourth_id_cut=explode("=",$third_id_cut);
if (isset($fourth_id_cut))
{
$curent_cat_id=$fourth_id_cut[1];
}

Thanks,

Roy.

jatar_k




msg:1260521
 5:21 pm on Nov 26, 2003 (gmt 0)

$fourth_id_cut=explode("=",$third_id_cut);
if (isset($fourth_id_cut[1])){
$curent_cat_id=$fourth_id_cut[1];
}

I would think you want to test the 2nd element to see if it is set.

royp2000




msg:1260522
 11:00 pm on Nov 26, 2003 (gmt 0)

o.k I'll try that.

Thanks.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved