Well, that's because your logic is flawed. If the title does NOT exist in the database, you won't have any result rows. Your else block is contained inside the while loop that iterates over the result rows.
When you think about it, it's totally obvious that the else should never execute, because you're not selecting any rows where the titles don't match.
More (unasked-for) comments:
Your query doesn't make sense. You're selecting all the 'title' column values where the column value is some fixed value ($title). As such, the query you wrote doesn't really do anything for you, since you're not really using the data you're selecting for any specific purpose. I mean, why select any data from the database when you already KNOW the data you're extracting?
What you're really trying to do is to determine whether any rows in the database contain a specific value in a specific column. More specifically -- you want the number of rows in the database where a specific value is found.
A better approach would be:
$query = "SELECT count(*) FROM info WHERE title='{$title}'";
$result = mysql_query($query);
if (FALSE === $result)
{
// error
}
else // query sucessfully executed
{
$count = mysql_result($result, 0);
if ($count > 0) // $title exists in the database.
{
// ask user to rename and resubmit.
}
else // $title does NOT exist in the database.
{
INSERT INTO info ...
}
}
Make sense?
Take care,
Nik
http://www.bigaction.org/