1

I want to prevent duplicate entry. It will work when I enter same name that is already exist but if I change it in to small letter it will not work. For example Already exist data is: Developer.If I enter Developer it give message already exist but I enter developer it will insert into database.

My code is as follow:

  function insert_skills()
  {
      extract($_POST);
      $user_id = $_SESSION['user_id'];
      $Qry = mysql_query("select `role_id` from `tbl_job_role` where`industry_id`='$industry_id' AND `funarea_id`='$funarea_id' AND `role_name`='$job_role'") or die(mysql_error());
      if(mysql_num_rows($Qry)>0)
      {
           echo "Already Exist!";
      }
      else
      {
              mysql_query("insert into `tbl_job_role`(`industry_id`,`funarea_id`,`role_name`,`created_by`,`created_on`) values('$industry_id','$funarea_id','$job_role','$user_id',NOW())") or die(mysql_error());
              setcookie("msg","Successfully Inserted.",time()+5);
       }
    }
user2870941
  • 27
  • 1
  • 6

3 Answers3

1

Hi use LOWER function for that

LOWER(`Value`) = LOWER("value")

Something like this

"select `role_id` from `tbl_job_role` where`industry_id`='$industry_id' AND `funarea_id`='$funarea_id' AND LOWER(`role_name`) = LOWER('$job_role')"
Sibiraj PR
  • 1,481
  • 1
  • 10
  • 25
0

Better you use LIKE

$Qry = mysql_query("select `role_id` from `tbl_job_role`
                    where`industry_id`='$industry_id' 
                       AND `funarea_id`='$funarea_id' 
                       AND `role_name` LIKE '$job_role'") or die(mysql_error());
GautamD31
  • 28,552
  • 10
  • 64
  • 85
0

Use iLIKE in your query. It will look like

$Qry = mysql_query("select `role_id` from `tbl_job_role` where`industry_id`='$industry_id' AND `funarea_id`='$funarea_id' AND `role_name` iLIKE '$job_role'") or die(mysql_error());

Please mark it as answer if it solves your problem.

Basit
  • 1,830
  • 2
  • 31
  • 50