you want to prevent someone from creating a category i the name already exists right?
i'd make something that follows this logic:
PHP Code:
/**
* store the $_POST[] array in seperate variables so they're easier to work with.
* use trim() to strip away any white space. i'd also use strtolower() and ucword to
* ensure people don't use horrid casing like DOwnlAdS.
**/
$name = ucwords(strtolower(trim($_POST['name'])));
/**
* the query is going to look for an exact match compared to what was
* through the form. the reason i suggest the ucwords() & strtolower()
* is because every title will follow the same naming convention and you
* won't run into comparing Downloads to DoWNLoADs and failing your
* cuplication check
**/
$query = "SELECT * from cats WHERE name = '$name'";
$result = mysql_query($query);
// check to see if we have a duplicate entry
if(count($result > 0) {
require_once("templates/header.html");
echo "<h3>Your category name has already been taken, please <a href=\"javascript:history.back();\">select another</a>.</h3><br>";
exit();
} else {
** any other db queries go here. IE adding the entry
}