Page 1 of 1

[SOLVED] I Want to get rid of this Warning: Undefined offset

Posted: Wed Jul 28, 2004 4:12 am
by dimitris
Can anyone explain me what is
Warning: Undefined offset: 2 in /home/blabla.bla/www/main.php on line 131


and how can i avoid it?

My script works fine but i want to get rid of that warning

of course without changing anything in php.ini

I have one page where i tick checkboxes with the name selectdb[]

and then i have the script:

Code: Select all

while($selected_dbї$i]!=''){
echo'<p align="center"><b>'.$selected_db&#1111;$i].'</b></p>';
$i++;
&#125;
Thanks a lot guys!

Posted: Wed Jul 28, 2004 4:35 am
by Weirdan
change while condition to isset($selected_db[$i]):

Code: Select all

while(isset($selected_db[$i])) {
  echo '<p align="center"><b>' . $selected_db[$i] . '</b></p>'; 
  $i++; 
}
or

Code: Select all

foreach($selected_db as $db) 
  echo '<p align="center"><b>' . $db . '</b></p>';

Posted: Wed Jul 28, 2004 4:54 am
by dimitris
Thanks! It worked and was so simple!