Reply to Re: create functions in "main" that requires Objects

Your name:

Reply:


Posted by Peter van Schie on 10/07/05 10:02

Siv Hansen wrote:

> then I have my "main"-page, where I try to make a function
> listSections()- like this:
> function listSections(){
> $sections = $connector->query("select * from section");<-- line 27
> while($result= $connector->fetchArray($sections)){
> print("<option>".$result['name']."</option>\n");
> }
> }

Hi Siv,

This seems like a scope problem to me. Where do you create the
$connector object? If it's outside of the function listSections, it
really is a scope problem.
If you created it in the same script where listSections resides (or in a
script that includes the php file containing the definition of
listSections, you could try:

function listSections(){
global $connector;
$sections = $connector->query("select * from section");
while($result= $connector->fetchArray($sections)){
print("<option>".$result['name']."</option>\n");
}
}

Peter.

--
http://www.phpforums.nl

[Back to original 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

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