Trying to set up a script to add "admins" to a database, but the part where it checks if the username is already taken appears to be fubar. Any help?
$query = "SELECT * FROM admins WHERE username = ".$_POST['username'];
$result = mysql_query($query);
$matches = mysql_num_fields($result);
if ($matches >= 1 )
{
echo "<h1>Error</h1><br>\n";
echo "<h3>Username is already taken. Go back and try again.</h3>\n";
include("foot.php");
exit;
}
The error I am receiving:
"Warning: mysql_num_fields(): supplied argument is not a valid MySQL result resource in /usr/local/www/test.thehellofit.com/public_html/infinitegames/admin.php on line 39"
(line 39 is: " $matches = mysql_num_fields($result);")
Anyone got any ideas?