lovethedog
06-18-2007, 10:27 PM
I am trying to create/call a function to check if a username exists during registration. I've created the following function (which I think is the problem, but can't be sure) in a file called functionsphp (which I put here so I could use the username exists check on other parts of the site):
function user_exists($username)
{
$result = $this->db->getVar("SELECT count(*) FROM accounts WHERE username = ?");
if ($result > 0) {
return true;
} else {
return false;
}
}
The idea here is to query the database for usernames, and if one is present, return a true. I'm trying to call it from a registration routine in registerphp, all of which is functioning properly except this one call:
$userexists = $functions->user_exists($username);
if ($userexists) {
$errors[] = "Sorry, that username is already taken. Please try again.";
}
When I execute this, I get a blank page back (from the smarty template).
Note - the register file does have a require_once declared for the function file, up top, and $username is the variable name for the username that is input on the form (and it is valid, as I've used it successfully for other tests in the registration process). Additional note - the reason I think the problem is the sql is because I actually tried running the function directly from the registration check script instead of calling it, and I get the same blank page.
What am I doing wrong here?
function user_exists($username)
{
$result = $this->db->getVar("SELECT count(*) FROM accounts WHERE username = ?");
if ($result > 0) {
return true;
} else {
return false;
}
}
The idea here is to query the database for usernames, and if one is present, return a true. I'm trying to call it from a registration routine in registerphp, all of which is functioning properly except this one call:
$userexists = $functions->user_exists($username);
if ($userexists) {
$errors[] = "Sorry, that username is already taken. Please try again.";
}
When I execute this, I get a blank page back (from the smarty template).
Note - the register file does have a require_once declared for the function file, up top, and $username is the variable name for the username that is input on the form (and it is valid, as I've used it successfully for other tests in the registration process). Additional note - the reason I think the problem is the sql is because I actually tried running the function directly from the registration check script instead of calling it, and I get the same blank page.
What am I doing wrong here?