title: How to send unique id into database usign mysql and php
body: <p>i created a application form and it has application no field. but it should be hidden. this application no should be auto increment unique number. i use date() and mysql_insert_id() method to generate that. but always show 0 value in my table. i have posted my code. please anyone can explain me..what is the error..about this case. this code is successfully inseterd. but did not show correct output. always show 0</p>
  
  <pre><code>if(isset($_POST['submitted'])){
  
  
      // catch data
      $loantype = $_POST['loantype'];
      $calcno = $_POST['calcno'];
      $memberid = $_POST['memberid'];
      $appno = date('Y-m-d')."-LN/SS-".mysql_insert_id();
      $amount = $_POST['amount'];
      $rental_type = $_POST['rental_type'];
      $apr = $_POST['apr'];
      $npy = $_POST['npy'];
      $flatrate = $_POST['flatRate'];
      $othercharges = $_POST['othercharges'];
      $repayment = $_POST['Repayment'];
  
  
      $payment = $_POST['payment'];
      $totpaid = $_POST['totpaid'];
      $intpaid = $_POST['intpaid'];
  
      date_default_timezone_set("Asia/Calcutta");
      $created = date('Y-m-d h:i:s');
      $status = "PENDING";
      $discription = "NOT DEFINED";
      $accepted_amount = "NOT DEFINED";
  
  
      //create new loan application
      $sql ='INSERT INTO tbl_loan_application VALUES (NULL,"'.$loantype.'","'.$calcno.'","'.$memberid.'","'.$appno.'","'.$amount.'","'.$rental_type.'","'.$apr.'","'.$npy.'","'.$flatrate.'","'.$othercharges.'","'.$repayment.'",
      "'.$created.'","'.$status.'","'.$discription.'","'.$accepted_amount.'","'.$payment.'","'.$totpaid.'","'.$intpaid.'")';
  
  
      /*else{
  
      }*/
  
  
          mysql_query($sql, $conn) or die(mysql_error());
          echo'&lt;div class="alert alert-dsgn alert-success fade in" style="width:400px; align:center; margin-left:35%;     margin-top:5px;&gt;
                              &lt;button class="close" aria-hidden="true" data-dismiss="alert" type="button"&gt;&lt;/button&gt;
                          &lt;i class="fa fa-thumbs-up fa-3x"&gt;&lt;/i&gt;
                          &lt;article&gt;
                          &lt;h4&gt;Nice! &lt;/h4&gt;
                          &lt;p&gt;New Loan application successfully saved..&lt;br /&gt; &lt;/p&gt;
                          &lt;/article&gt;
                      &lt;/div&gt;';
      echo '&lt;a href="newloan.php"&gt;&lt;p align="center"&gt;Back&lt;/p&gt;&lt;/a&gt;';    
      echo '&lt;p align="center"&gt;If you want to view loan application! click &lt;a href="approved_loan_list.php"&gt;here&lt;/a&gt;&lt;/p&gt;'; 
      echo mysql_insert_id();
      die();
  
  
      //
  
  }
  </code></pre>