Log in

View Full Version : Problem add new entry in to mysql table with php.



mehidy
03-01-2011, 10:54 AM
Dear All

I am using below script to add new entry in to my database, but problem is, after adding one entry I can't add new entry at the same time. If I do so its shows updating error. After 10 to 20 minutes, I can add new entry. Can any one tell me whats wrong in it?

You can see my form at

http://mehidy.pcriot.com/ordersdetails/New128.php




<?php

$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="merchandising"; // Database name
$tbl_name="ordersummery1"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
echo "mehidy";
?>


<?php

if(isset($_POST['submit'])){
//company details
$uniqkey= $_POST['uniqkey'];

$unit= $_POST['unit'];
$factory = $_POST['factory'];
$fdepartment = $_POST['fdepartment'];
$designation = $_POST['designation'];
$mrchand_name = $_POST['mrchand_name'];
$secret_code=$_POST['secret_code'];
$fact_rmks = $_POST['fact_rmks'];
//buyer details
$buyinghouse = $_POST['buyinghouse'];
$buyer = $_POST['buyer'];
$customer = $_POST['customer'];
$departmentname_no = $_POST['departmentname_no'];
$department_for = $_POST['department_for'];
$brand = $_POST['brand'];
$sub_brand = $_POST['sub_brand'];
$buyer_mer = $_POST['buyer_mer'];
$buyer_rmks = $_POST['buyer_rmks'];
//orders details
$year = $_POST['year'];
$season = $_POST['season'];
$order_no = $_POST['order_no'];
$ship_date = $_POST['ship_date'];
$items= $_POST['items'];
$size_range= $_POST['size_range'];
$end_user= $_POST['end_user'];
$wash= $_POST['wash'];
$print= $_POST['print'];
$emb= $_POST['emb'];
$unitin= $_POST['unitin'];
$pricein= $_POST['pricein'];
$ord_rmks= $_POST['ord_rmks'];
$ttlcombo= $_POST['ttlcombo'];
$ttlfabcol= $_POST['ttlfabcol'];
$qty= $_POST['qty'];
$unitprice= $_POST['unitprice'];
//fabrics details
$fab_type1= $_POST['fab_type1'];
$fab_name1= $_POST['fab_name1'];
$fab_comp1= $_POST['fab_comp1'];
$gsm1= $_POST['gsm1'];
$spcialeft1= $_POST['spcialeft1'];
$yarncount1= $_POST['yarncount1'];
$useat1= $_POST['useat1'];
$fab_rmks1= $_POST['fab_rmks1'];

$fab_type2= $_POST['fab_type2'];
$fab_name2= $_POST['fab_name2'];
$fab_comp2= $_POST['fab_comp2'];
$gsm2= $_POST['gsm2'];
$spcialeft2= $_POST['spcialeft2'];
$yarncount2= $_POST['yarncount2'];
$useat2= $_POST['useat2'];
$fab_rmks2= $_POST['fab_rmks2'];
//LC Details
$master_lc_no= $_POST['master_lc_no'];
$lc_date= $_POST['lc_date'];
$lc_receiving_date= $_POST['lc_receiving_date'];
$lc_shipment_date= $_POST['lc_shipment_date'];
$lc_expire_date= $_POST['lc_expire_date'];
$ship_mood= $_POST['ship_mood'];
$payments_terms= $_POST['payments_terms'];
$lc_amount= $_POST['lc_amount'];
$destination= $_POST['destination'];
$lc_rmks= $_POST['lc_rmks'];
//Shipping line details
$shipping_line= $_POST['shipping_line'];
$shipping_port = $_POST['shipping_port'];
$office_phone = $_POST['office_phone'];
$office_email = $_POST['office_email'];
$contact_person = $_POST['contact_person'];
$cell_no = $_POST['cell_no'];
$email_id = $_POST['email_id'];


//check to see if any of the boxes were not filled in
if(!$unit ){
//if any weren't display the error message
echo "<center>You need to fill in all of the required filds!</center>";
}
else{

//insert the row into the database table
//valu data s/b maintain the mysql table serial such as buyer/subbrand/dept, it s/b not be buyer/dept/subbrand & so on

$query = "INSERT INTO $tbl_name (uniqkey,unit,factory,fdepartment,designation,mrchand_name,secret_code,fact_rmks,buyinghouse,buyer,customer,departmentname_no,
department_for,brand,sub_brand,buyer_mer,buyer_rmks,year,season,order_no,ship_date,items,size_range,end_user,wash,print,emb,unitin,
pricein,ord_rmks,ttlcombo,ttlfabcol,qty,unitprice,fab_type1,fab_name1,fab_comp1,gsm1,spcialeft1,yarncount1,useat1,fab_rmks1,
fab_type2,fab_name2,fab_comp2,gsm2,spcialeft2,yarncount2,useat2,fab_rmks2,master_lc_no,lc_date,lc_receiving_date,lc_shipment_date,
lc_expire_date,ship_mood,payments_terms,lc_amount,destination,lc_rmks,shipping_line,shipping_port,office_phone,office_email,contact_person,cell_no,email_id) VALUES ('$uniqkey','$unit','$factory',
'$fdepartment','$designation','$mrchand_name','$secret_code','$fact_rmks','$buyinghouse','$buyer','$customer','$departmentname_no',
'$department_for','$brand','$sub_brand','$buyer_mer','$buyer_rmks','$year','$season','$order_no','$ship_date','$items','$size_range',
'$end_user','$wash','$print','$emb','$unitin','$pricein','$ord_rmks','$ttlcombo','$ttlfabcol','$qty','$unitprice',
'$fab_type1','$fab_name1','$fab_comp1','$gsm1','$spcialeft1','$yarncount1','$useat1','$fab_rmks1','$fab_type2','$fab_name2','$fab_comp2',
'$gsm2','$spcialeft2','$yarncount2','$useat2','$fab_rmks2','$master_lc_no','$lc_date','$lc_receiving_date','$lc_shipment_date',
'$lc_expire_date','$ship_mood','$payments_terms','$lc_amount','$destination','$lc_rmks','$shipping_line','$shipping_port','$office_phone','$office_email','$cont act_person','$cell_no','$email_id')";

$result=mysql_query($query) or die('Error updating data base/Please Check your unique key');

//display the success message
echo "<center>You have successfully added new orders details for: '$factory'</center>" ;

}
}

?>