Reputation: 1
I am trying to check for duplicate data before inserting to the database, but, it still giving me errors, I have tried all my possible means, but I honestly don't know where I missed it
$dupesql = "SELECT * FROM table where (name = '$name' AND description = '$description' AND manufacturer = '$manufacturer' AND city ='$city' AND price = '$price' AND enddate = '$end_date')";
$duperaw = mysql_query($dupesql);
if (mysql_num_rows($duperaw) > 0)
but I keeping getting this result
Warning: mysqli_query() [function.mysqli-query]: Empty query in C:\wamp\www\sug2019\form_processors\dgs_processor.php on line 52
Upvotes: 0
Views: 76
Reputation: 1403
Try to solve your issue with mysqli
instead of mysql
$dupesql = mysqli_query($con,"SELECT * FROM table where name = '$name' AND description = '$description' AND manufacturer = '$manufacturer' AND city ='$city' AND price = '$price' AND enddate = '$end_date'");
if(mysqli_num_rows($dupesql)<=0){
// No duplicate data found
}else{
// Duplicate Data found
}
In this $con
is your connection file variable
Upvotes: 2