if( user_exists("foobar"))
{
// will this ever execute?
}
else
{
// or this???
}
function user_exists($username){
$username = sanitize($username);
$sql = "SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username'";
$result = mysql_query($sql);
if(!$result) {
echo "There was a error in the following sql statement : <br>".$sql;
//maybe a throw new Exception goes here
}
/* start patch */
// Don't you want to return true or false here?
if( mysql_num_rows($result) > 0 ) {
return true;
}else {
return false;
}
/* end patch */
}
*** EDIT ***
wow, I really am batting 1,000 today..
I didn't notice your query was "SELECT COUNT(*)" ... My patch may not work if you use COUNT(*).
Better to change your query to select an ID from the table.

New Topic/Question
Reply




MultiQuote





|