I've had this problem before, but in other ways. I can't get things to work inside functions. I'm guess it's because of the way I am handling my variables, but can somebody please explain why the following does not work inside a function?
$db = mysql_connect($conf_db_host,$conf_db_username,
$conf_db_password);
mysql_select_db($conf_db_database,$db);
function usernametaken($username) {
$sql="SELECT * FROM nnblog_users WHERE username='$username'";
$result=mysql_query($sql);
$num_rows=mysql_num_rows($result);
if ($num_rows>0) {
return true;
}
else {
return false;
}
}
The purpose of the function is to return true if a username has already been registered.
I get this error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\program files\appserv\www\nnblog\register.php on line 9