I’m trying to create a member registration page. I need it to check to see if a username is taken already. So i thought I could do this
[code=php]
$username = $_REQUEST[‘username’];
$query = “select * from member_list where username='”.$username.”‘”;
$result = mysql_query($query);
then, if there is no entry in the database, then I thought it would return a false value for $result. Problem is, it returns a true value. And if I do this
[code=php]
$row=mysql_fetch_array($result);
$name = stripslashes($row[‘username’]);
echo $name;
then it just keeps echoing the value of $username, whatever I put it, and whether or not it’s in the database!? I don’t understand it….surely if the name specified in $username is NOT in the database, then the MYSQL query should not return anything?
Is there another way to find if something already exists in a database? Or will I have to use a for loop to check the value of every entry in teh database against the username?
Thanks
Toby