Jump to content

[SOLVED] how to makesure no duplicate entries with alert box


girlzz

Recommended Posts

<?php

$query = mysql_query("SELECT COUNT(*) FROM table WHERE data='$data'");
$num = mysql_num_rows($query);

if ($num > 0){
   echo "Duplicate!!";
}

?>

 

mysql_num_rows() will always return 1 row using this method, unless of course the query fails. Try...

 

if ($result = mysql_query("SELECT COUNT(*) FROM table WHERE data='$data'")) {
  if (mysql_result($res,0) > 0) {
    echo "Duplicate!!";
  }
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.