What I'm trying to do is check with the MySQL database to see if the username I'm presenting it with exists. If it exists, it says "Username Unvailable" and if it doesn't exist it says "Username Available".
If you just want to check to see if the username is a duplicate, then you have the right idea, just that your implementation is not correct. JVassie's implementation is not correct either, though it comes close.
A more correct example would be:
<?php
// Connect to the MySQL
$link = mysql_connect('localhost', 'spowpow1_Sean', '<password>')
or die('Not connected : ' . mysql_error());
// select test as the current db
$db_selected = mysql_select_db('spowpow1_test', $link)
or die('Database not selected : ' . mysql_error($link));
$username = 'LOLOL';
$query = sprintf("SELECT COUNT(*) FROM people2 WHERE userName = '%s'",
mysql_real_escape_string($username, $link));
$result = mysql_query($query, $link)
or die(mysql_error($link));
if (mysql_result($result, 0) == 0) {
echo 'Username Available';
}
else {
echo 'Username Unavailable';
}
mysql_close($link);
?>
However, if you actually want to insert the new user's records, then you should simply declare the username column UNIQUE. Then attempt to insert, and catch the duplicate error if there is one.