There is no more support for mysql_* functions, they are officially deprecated, no longer maintained and will be removed in the future. You should update your code with PDO or MySQLi to ensure the functionality of your project in the future.
mysql_query
returns a resource
rather than the result set. So $checkname > 0
will always be true. You need to then fetch with mysql_fetch_assoc
You should change the query command to mysqli_query
. And check the results of $checkname->fetch_row()
http://us2.php.net/manual/en/mysqli.query.php