I have a table,
id / category / extra / another
I would like to check a row in the table for duplicate entries.
for example:
services / plumbing / residential
The above can only exist once.
But...
construction / plumbing / residential
The above can exist too.
So i have to check all three fields together in the one row?
My code wont work.
<?php
// connect here
//
$category = mysql_real_escape_string($_POST['category']);
$extra = mysql_real_escape_string($_POST['extra']);
$another = mysql_real_escape_string($_POST['another']);
$querySTATUS = "SELECT * FROM categories WHERE category ='.$category.' AND extra ='.$extra.' AND another ='.$another'";
$resultSTATUS = mysql_query($querySTATUS) or die(mysql_error());
$CountRows = mysql_num_rows($resultSTATUS);
if($CountRows == 1){
echo "OK";
$query1 = "INSERT INTO categories (category,extra,another) VALUES ( '$category','$extra','$another')";
$result = mysql_query($query1) or die(mysql_error());
} else {echo "!OK";}exit;?>
I have a 3input fields that post the data obviously.
Also the responses OK and !OK are there to run some inline jquery on the form page.
I just keep getting !OK response in firebug, i have tried variations of the query but to no success.
Thank you in advance if you can help :-)
John