You are here: Objects and Arrays « PHP Programming Language « IT news, forums, messages
Objects and Arrays

Posted by TKirahvi on 04/02/07 06:35

Why can't I create Objects in an Array within for/while loop?

If I have:

Code:

$galleries = array();

while( $db->next_record() )
{
$foo = $db->f('id');
$galleries[] = new Gallery($foo);
}


Database query returns two id's and galleries array should then
contain two Gallery Objects but it contains only the first one.

If I do it like this, it works fine:

Code:

$galleries[] = new Gallery(1);
$galleries[] = new Gallery(2);


I have PHP 5.1.6

Thanks in advance

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация