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?
Navigation:
[Reply to this message]
|