Bobbo171
01-08-2007, 07:07 AM
I have a registration class with the following method to verify that the username doesn't already exist in the database
function checkUsername(){
$q = sprintf("SELECT COUNT(*) AS ucount FROM user WHERE username = '%s'", $this->myUser->getUsername());
$ucount = $db->result($db->query($q), "result", 0); //error line
if($ucount > 0){
$this->error = true;
$this->errors .= "-Username already exists\n";
}
}
the error I get is this
Fatal error: Call to a member function result() on a non-object in C:\Program Files\xampp\htdocs\clsRegister.php on line 44
and I cant figure out what is going wrong, the database functions that are being used are
public function query($query){
return mysql_query($query);
}
public function result($result, $type = 'assoc', $row = 0){
switch ($type){
case 'assoc':
return mysql_fetch_assoc($result);
break;
case 'row':
return mysql_fetch_row($result);
break;
case 'num_rows':
return mysql_num_rows($result);
break;
case 'result':
return mysql_result($result, $row);
break;
}
}
I've searched around for a while but couldn't find anything too useful to help me out. Any help is greatly appreciated:D Thanks!
function checkUsername(){
$q = sprintf("SELECT COUNT(*) AS ucount FROM user WHERE username = '%s'", $this->myUser->getUsername());
$ucount = $db->result($db->query($q), "result", 0); //error line
if($ucount > 0){
$this->error = true;
$this->errors .= "-Username already exists\n";
}
}
the error I get is this
Fatal error: Call to a member function result() on a non-object in C:\Program Files\xampp\htdocs\clsRegister.php on line 44
and I cant figure out what is going wrong, the database functions that are being used are
public function query($query){
return mysql_query($query);
}
public function result($result, $type = 'assoc', $row = 0){
switch ($type){
case 'assoc':
return mysql_fetch_assoc($result);
break;
case 'row':
return mysql_fetch_row($result);
break;
case 'num_rows':
return mysql_num_rows($result);
break;
case 'result':
return mysql_result($result, $row);
break;
}
}
I've searched around for a while but couldn't find anything too useful to help me out. Any help is greatly appreciated:D Thanks!