Reply to create functions in "main" that requires Objects

Your name:

Reply:


Posted by Siv Hansen on 10/08/05 02:28

I have a function query(String $query) in my DbConnector-class- goes
like this:
function query($query) {
$mysqlQuery = mysql_query($query, $this->link);
if(!$mysqlQuery){
$this->setError("Queryfeil: ".mysql_error());
return false;
}
return $mysqlQuery;
}
and the fetchArray($result)-function:
function fetchArray($result) {
$output = mysql_fetch_array($result);
if(!$output){
$this->setError("Feil under henting fra databasen: ".mysql_error());
return false;
}
return $output;
}

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");
}
}

when I try to run this function I get an error message:
Fatal error: Call to a member function query() on a non-object in
c:\wamp\www\cms\cmsadmin\section.php</b> on line 27

Is it possible to do what I'm thinking? To create a function who
involves objects?

[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

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