Hi! I can’t figure out what I’m doing wrong. Any help is greatly appreciated. Thanks, in advance!
$username_query = mysql_query(“SELECT (
name_username = ‘$username’”);
$username_result = mysql_result($username_query,0);
if($username_result == 0)
echo ‘Username already exists.’;
elseif (strlen($username) < 6 || strlen($username) > 15)
echo “Username must be 6 to 15 characters”;
elseif (preg_match("/^[a-zA-Z1-9]+$/", $username))
echo ‘Username is available.’;
echo ‘Use alphanumeric characters only.’;
Here’s the form that goes with it:
[code]<form action=’<?=$_SERVER['PHP_SELF']?>’ method=‘post’>register for a new account desired username: <? checkUserName(); ?> first name: last name: desired password: re-enter password log in if you already have an accountusername:password: [/code] I've already tried running the SQL in PhpMyAdmin, so I'm pretty sure the problem lies in the PHP. Right now, I'm getting the error: Warning: mysql_result() expects parameter 1 to be resource, boolean given in /Users/justinalba/Sites/php-class/module3/registration.php on line 40 and it is saying all usernames are available when I am purposefully putting in one that matches in my DB.