I have a MySQL database and a table ('urls') with several records in.

Before I submit a new one I need to check if a record with the submitted data already exists - in which case there is no point in creating a new one because it already exists!

Code PHP:
    $query = "SELECT * FROM urls WHERE url = '{$url}'";
    $result = mysql_query($query,CONNECTION);
    if($result) echo 'Already exists!!! :)';
    else echo 'Sorry, it doesn\'t exist yet so you\'ll have to create a new record. :(';

When I enter the query (SELECT * FROM urls WHERE url = 'example value') directly in the mySQL it returns several rows of data which is what it should do.

The problem is that the above function does not work! The if($result) condition is not being met for some reason - I cannot understand this because the query should be returning several rows of data!