Duplication

I am trying to make a form which checks a database to see if a record exists but it isn’t going according to plan.

I have the following code

[php]

if ($_POST[‘name’]>"") {
$checkname = $name;
$check = “SELECT name FROM destinations WHERE name = '” . $checkname . “’”;
$check1=mysql_query($check, $con) or die(mysql_error());
if($check1 > 0) {
echo “$checkname already exists!!”;
}
else
{
echo “$checkname added!!”;
}
}

[/php]

If I change [php] if($check1 > 0) [/php] to == or $check I get added or alredy exhists respectively for everything I type

Sorted it

[php]
if(mysql_num_rows($check1) > 0)
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service