title: 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2147483647' for key 'contact_no'
body: <p>I am facing a problem whenever i tried to fill my form and field Contact no &amp; Phone no it automatically generate its own static no. every time and as i had given "UNIQUE" to my key 'Contact_no' it generates error this "</p>
  
  <blockquote>
    <p>exception 'PDOException' with message 'SQLSTATE[23000]: Integrity
    constraint violation: 1062 Duplicate entry '2147483647' for key
    'contact_no'' in C:\wamp\www\ipsem6\connectivity.php:34 Stack trace:
    0 C:\wamp\www\ipsem6\connectivity.php(34): PDO->exec('INSERT INTO a8...') #1{main}`"</p>
  </blockquote>
  
  <p>Below is my code of my register.php page</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  
  &lt;title&gt;Register&lt;/title&gt;
  &lt;style&gt;
  
  .content:before {
  content: "";
  position: fixed;
  left:34px;
  right:0;
  top:90px;
  bottom:20px;
  z-index: -1;
  
  display: block;
  background-image: url('assets/img/cd.JPG');
  width: 1281px;
  height: 8000px;
  
  
  -webkit-filter: blur(5px);
  -moz-filter: blur(5px);
  -o-filter: blur(5px);
  -ms-filter: blur(5px);
  filter: blur(5px);
  }
  
  .content {
  overflow: auto;
  position: static;
  
  left: 0;
  right: 0;
  z-index: 0;
  margin-left: 0;
  margin-right: 0;
  }
  
  &lt;/style&gt;
  &lt;link rel="STYLESHEET" type="text/css" href="style/fg_membersite.css" /&gt;
  &lt;script type='text/javascript' src='scripts/gen_validatorv31.js'&gt;&lt;/script&gt;
  &lt;link rel="STYLESHEET" type="text/css" href="style/pwdwidget.css" /&gt;
  &lt;script src="scripts/pwdwidget.js" type="text/javascript"&gt;&lt;/script&gt;  
  &lt;link rel="stylesheet" href="style/style1.css" type="text/css" /&gt;    
  &lt;/head&gt;
  &lt;body   class="body" &gt;
  &lt;div class="content"&gt;
  &lt;header class="mainheader" &gt;
  
  &lt;div class="canmenu"&gt;
  
  &lt;div class="left mtop10"&gt;&lt;a href="http://www.chitkara.edu.in/" title=""     rel="home"&gt;
  &lt;img src="assets/img/chitkara_logo.png" /&gt;&lt;/a&gt;
      &lt;/div&gt;
     &lt;div id="cssmenu"&gt;
          &lt;nav&gt;&lt;ul&gt;
             &lt;li&gt;&lt;a href="index.html"&gt;&lt;span&gt;&lt;b&gt;Home&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
  
             &lt;li&gt;&lt;a href="#"&gt;&lt;span&gt;&lt;b&gt;About Us&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
  
             &lt;li&gt;&lt;a href="login.html"&gt;&lt;span&gt;&lt;b&gt;Login&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
  
             &lt;li class="active"&gt;&lt;a href="register.php"&gt;&lt;span&gt;&lt;b&gt;Register&lt;/b&gt; &lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
  
             &lt;li class="last"&gt;&lt;a href=""&gt;&lt;span&gt;&lt;b&gt;Contact us&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;&lt;/nav&gt;
      &lt;/div&gt;
  
      &lt;!--&lt;div class="can-menu"&gt;
                  &lt;/div&gt;--&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;!-- Form Code Start --&gt;
  
  &lt;center&gt;&lt;div id='fg_membersite' &gt;
  &lt;form id='register'  method='post' action="connectivity.php" accept-charset='UTF-8' &gt;
  
  &lt;br&gt;
  &lt;br&gt;
  
  
  &lt;fieldset &gt;
  
  &lt;legend&gt;&lt;h1&gt;&lt;font size="40" color="BLACK"&gt;&lt;b&gt;&lt;center&gt;&lt;img src="assets/img/canfinal1.jpg" height="100px" width="150px"/&gt;&lt;font color="WHITE"&gt;Register&lt;/font&gt;&lt;/b&gt;&lt;/font&gt;&lt;/h1&gt;&lt;/legend&gt;
  
  &lt;input type='hidden' name='submitted' id='submitted' value='1'/&gt;
  
  &lt;div class='short_explanation'&gt;&lt;font size="2" color="RED"&gt;&lt;b&gt;* required fields&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;
  &lt;input type='text'  class='spmhidip'  /&gt;
  
  &lt;div&gt;&lt;span class='error'&gt; &lt;/span&gt;&lt;/div&gt;
  &lt;div class='container'&gt;
  &lt;label for='name' &gt;&lt;font color="WHITE"&gt;Your Full Name&lt;font color="RED"&gt;&lt;b&gt;*&lt;/b&gt;&lt;/font&gt; :&lt;/label&gt;&lt;br/&gt;
  &lt;input type='text' name='name' id='name'  maxlength="50" /&gt;&lt;br/&gt;
  &lt;span id='register_name_errorloc' class='error'&gt;&lt;/span&gt;
  &lt;/div&gt;
  &lt;div class='container'&gt;
  &lt;label for='email' &gt;&lt;font color="WHITE"&gt;Email Address&lt;font color="RED"&gt;&lt;b&gt;*&lt;/b&gt;&lt;/font&gt; :&lt;/label&gt;&lt;br/&gt;
  &lt;input type='text' name='email' id='email'  maxlength="50" /&gt;&lt;br/&gt;
  &lt;span id='register_email_errorloc' class='error'&gt;&lt;/span&gt;
  &lt;/div&gt;
  &lt;div class='container'&gt;
  &lt;label for='username' &gt;&lt;font color="WHITE"&gt;UserName/University Id&lt;font color="RED"&gt;&lt;b&gt;*&lt;/b&gt;&lt;/font&gt; :&lt;/label&gt;&lt;br/&gt;
  &lt;input type='text' name='username' id='username'  maxlength="50" /&gt;&lt;br/&gt;
  &lt;span id='register_username_errorloc' class='error'&gt;&lt;/span&gt;
  &lt;/div&gt;
  
  &lt;div class='container'&gt;
  &lt;label for='contacts1' &gt;&lt;font color="WHITE"&gt;Contact No.&lt;font color="RED"&gt;&lt;b&gt;*&lt;/b&gt;&lt;/font&gt; :&lt;/label&gt;&lt;br/&gt;
  &lt;input type='phone' name='contacts1' id='contacts1'   /&gt;&lt;br/&gt;
  
  &lt;/div&gt;
  
  &lt;div class='container'&gt;
  &lt;label for='contact2' &gt;&lt;font color="WHITE"&gt;Phone No. :&lt;/label&gt;&lt;br/&gt;
  &lt;input type='tel' name='contact2' id='contact2'   /&gt;&lt;br/&gt;
  
  &lt;/div&gt;
  
  
  &lt;div class='container' &gt;
  &lt;label for='password' &gt;&lt;font color="WHITE"&gt;Password&lt;font color="RED"&gt;&lt;b&gt;*&lt;/b&gt;&lt;/font&gt; :&lt;/label&gt;&lt;br/&gt;
  &lt;div class='pwdwidgetdiv' id='thepwddiv' &gt;&lt;/div&gt;
  &lt;noscript&gt;
  &lt;input type='password' name='password' id='password' maxlength="50" /&gt;
  &lt;/noscript&gt;    
  &lt;div id='register_password_errorloc' class='error' style='clear:both'&gt;&lt;/div&gt;
  &lt;/div&gt;
  
  
  
  
  
  &lt;div class='container'&gt;
  &lt;label for='date' &gt;&lt;font color="WHITE"&gt;Date of Birth&lt;font color="RED"&gt;&lt;b&gt;*&lt;/b&gt;&lt;/font&gt; :&lt;/label&gt;&lt;br/&gt;
  &lt;input type='date' name='dats' id='dats'  maxlength="50" /&gt;&lt;br/&gt;
  &lt;span id='register_username_errorloc' class='error'&gt;&lt;/span&gt;
  &lt;/div&gt;
  
  &lt;div class='container' &gt;
  &lt;label&gt;&lt;font color="WHITE"&gt;Role&lt;font color="RED"&gt;&lt;b&gt;*&lt;/b&gt;&lt;/font&gt; :&lt;/label&gt;
  &lt;select  name='rle' id='rle'  maxlength="50" &gt;
  &lt;option value="Alumni"&gt;Alumni&lt;/option&gt;
  &lt;option value="Mentor"&gt;Mentor&lt;/option&gt;
  &lt;option value="H.O.D"&gt;H.O.D&lt;/option&gt;
  
  &lt;/select&gt;
   &lt;span id='register_username_errorloc' class='error'&gt;&lt;/span&gt;
  
  
  &lt;/div&gt;
  
  &lt;div id="q1" class="form-group"&gt;
  &lt;label&gt;&lt;font color="WHITE"&gt;Gender&lt;font color="RED"&gt;&lt;b&gt;*&lt;/b&gt;&lt;/font&gt; :&lt;/label&gt;
  &lt;select class="form-control"  id="s" name="s"&gt;
  &lt;option value="Male" &gt;Male&lt;/option&gt;
  &lt;option value="Female"&gt;Female&lt;/option&gt;
  &lt;/div&gt;
  &lt;/select&gt;
  
  
  
  &lt;div class='container'&gt;
  &lt;input type='submit' name='Submit' value='Submit' color="blue" /&gt;
  &lt;/div&gt;
  
  &lt;/fieldset&gt;
  &lt;/form&gt;
  &lt;!-- client-side Form Validations:
  Uses the excellent form validation script from JavaScript-coder.com--&gt;
  
  &lt;script type='text/javascript'&gt;
  // &lt;![CDATA                                                                                         
  var pwdwidget = new PasswordWidget('thepwddiv','password');
  pwdwidget.MakePWDWidget();
  
  var frmvalidator  = new Validator("register");
  frmvalidator.EnableOnPageErrorDisplay();
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("name","req","Please provide your name");
  
  frmvalidator.addValidation("email","req","Please provide your email address");
  
  
  
  frmvalidator.addValidation("username","req","Please provide your University ID.");
  
  frmvalidator.addValidation("password","req","Please provide a password");
  
  frmvalidator.addValidation("date","req","Please provide your D.O.B");
  
  // ]]&gt;
  &lt;/script&gt;
  
  &lt;!--
  Form Code End
  --&gt;
  
  &lt;/div&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>Below is my code of connectivity.php</p>
  
  <pre><code>&lt;?php
  // DATABASE CONNECTIVITY &amp; UPLOADING ----&gt; 
  $connection_error = 'Could Not Connect to server.';
  $connection_error2 = 'Could Not Connect to database.';
  
  $host = 'localhost';
  $user = 'root';
  $password = '';
  $database = 'a8172058_portal';
  $dsn = "mysql:host=$host;dbname=$database";
  try {
     $conn = new PDO( $dsn, $user, $password );
     $conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  
  
  
  
        $name=$_POST["name"];
        $email=$_POST["email"];
        $username=$_POST['username'];
        $pass=$_POST['password'];
        $contactno=$_POST['contacts1'];
        $cont2=$_POST['contact2'];
        $dob=$_POST['dats'];
        $role=$_POST['rle'];
        $gender=$_POST['s'];
  
  
  
  
         $sql= "INSERT INTO `a8172058_portal`.`users`  (email,univ_id,password,full_name,role,gender,contact_no1,contact_no2,dob) 
         VALUES   ('$email','$username','$pass','$name','$role','$gender','$contactno','$cont2','$dob');";
  
        $conn-&gt;exec($sql);
             print "&lt;meta http-equiv=\"refresh\" content=\"0;URL=form1.html\"&gt;";
         }
              catch(PDOException $e)
               {
                 print ($e);
                 //print "&lt;meta http-equiv=\"refresh\" content=\"0;URL=error.html\"&gt;";
                }
  
               $conn = null;
  
  
  
  
    ?&gt;
  </code></pre>
  
  <p>Please Help me solving this Problem . My DM is 
  <a href="https://i.stack.imgur.com/Cgadn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Cgadn.png" alt="enter image description here"></a></p>
  
  <p>No matter what value i give it always give that static value marked in image below.
  <a href="https://i.stack.imgur.com/YyE77.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YyE77.png" alt="enter image description here"></a></p>