Could anyone tell me what is wrong here. The script check the database to see if a record exists, if it does it says so, otherwise it inserts the record.
Currently it always says the record exists
IF ($type=="add") {
$sql = "SELECT count(*) FROM product_table WHERE product = $product";
$result = mysql_query ($sql);
if ($result)
{
$row = mysql_fetch_row ($result);
if ($row[0] == 0) // thats the value of count(*)
{
$insert_sql = "INSERT INTO product_table (product)
VALUES ('$product')";
$insert_result = mysql_query($insert_sql) or die ("Couldn't execute query----Insert Product");
if (!$insert_result) {
echo "Couldn't add product!";}
}
}
else
{
$message =" This record already exists";
}
Cheers for any help
Matt