After repeated writes to the database, the same query statement cannot be queried.

Source: Internet
Author: User
After repeated writes to the database, the same query statement cannot be queried. & lt ;? Phpset_time_limit (0); & nbsp; $ filepath =$ _ GET ['uploadfile']; require_once & nbsp ;'.. /conn. php '; after error_re is repeatedly written to the database, no results can be found for the same query statement.


Set_time_limit (0 );

$ Filepath = $ _ GET ['uploadfile'];
Require_once '../conn. php ';

Error_reporting (E_ALL ^ E_NOTICE );

$ Line = 0;
$ Shipments = 0;
$ I = 0;
$ S = 0;
$ F = 0;

$ StrSqla = "select max (number) FROM 'Sale _ orders_restock '"; // query the maximum value of the id field in the sale_orders_restock table
$ Querya = mysql_query ($ strSqla, $ conn );
$ Resultaa = mysql_fetch_row ($ querya );
$ Maxnum = $ resultaa [0];
$ Maxnum ++;


$ File = fopen ($ filepath, "r") or die ("failed to open the file ");

While (! Feof ($ file )){

$ Buffer = fgets ($ file );

If ($ line <> 0)
{


$ U = explode ('', trim ($ buffer ));
If (! Empty ($ u [0]) {


$ Sku = $ u [10];

$ SQL _itemcode = "SELECT * FROM 'sku _ rule' WHERE 'sku '=' $ sku '";
$ Querya = mysql_query ($ SQL _itemcode, $ conn );
$ Rs = mysql_fetch_array ($ querya );



$ J_sku = $ rs ['item _ Code'];
$ Delivery_areas = $ rs ['delivery _ areas'];
$ Zhanghao = $ rs ['account'];



$ Or_id = $ u [0];
$ Or_it_id = $ u [1];
$ Payments_date = $ u [3];


$ Buyer_email = $ u [7];
$ Buyer_name = mb_convert_encoding (addslashes ($ u [8]), 'utf-8', 'utf-8, shft-jis, gbk ');
$ Buyer_phone = mb_convert_encoding (addslashes ($ u [9]), 'utf-8', 'utf-8, shft-jis, gbk ');


$ Product_name = mb_convert_encoding (addslashes ($ u [11]), 'utf-8', 'utf-8, shft-jis, gbk ');
$ Quantity = $ u [12];

$ Recipient_name = mb_convert_encoding (addslashes ($ u [16]), 'utf-8', 'utf-8, shft-jis, gbk ');
$ Ship_address1 = mb_convert_encoding (addslashes ($ u [17]), 'utf-8', 'utf-8, shft-jis, gbk ');
$ Ship_address2 = mb_convert_encoding (addslashes ($ u [18]), 'utf-8', 'utf-8, shft-jis, gbk ');
$ Ship_address3 = mb_convert_encoding (addslashes ($ u [19]), 'utf-8', 'utf-8, shft-jis, gbk ');


$ Ship_city = mb_convert_encoding (addslashes ($ u [20]), 'utf-8', 'utf-8, shft-jis, gbk ');
$ Ship_state = mb_convert_encoding (addslashes ($ u [21]), 'utf-8', 'utf-8, shft-jis, gbk ');
$ Ship_postal = mb_convert_encoding (addslashes ($ u [22]), 'utf-8', 'utf-8, shft-jis, gbk ');
$ Ship_country = mb_convert_encoding ($ u [23], 'utf-8', 'utf-8, shft-jis, gbk ');
$ Cancel_order = 0;
$ Logistics_number = "";
$ Logistics_company = "";


$ StrSql_item = "SELECT * FROM 'jperp'. '1 _ item_codes 'Where 'item _ code' = '$ j_sku '";
$ Query_item = mysql_query ($ strSql_item, $ conn );
$ Rs = mysql_affected_rows ();
$ Kit = 0;
If ($ rs> 1)
{
While ($ rs = mysql_fetch_array ($ query_item )){
$ Or_it = "";
$ J_sku = $ rs ['stock _ id'];

$ Item_quantity = $ rs ['quantity '];
$ Quantity = $ quantity * $ item_quantity;

If ($ kit> 0 ){
$ Or_it = $ or_it_id. $ kit;
}
Else
{
$ Or_it = $ or_it_id;
}

$ SQL _sale = "INSERT INTO 'Amazon _ erp '. 'sale _ orders_restock' ('number', 'Order _ id', 'Order _ item_id ', 'shipment', 'Payments _ date', 'buyer _ email ', 'buyer _ name', 'buyer _ phone_number ', 'sku', 'JJ _ SKS', 'product _ name', 'quantity _ purchased', 'recipient _ name ', 'ship _ ssss_1 ', 'ship _ address_2', 'ship _ address_3 ', 'ship _ state', 'ship _ postal_code', 'ship _ country ', 'account ', 'ship _ City', 'cel _ order', 'delimitery_areas', 'logistics _ number', 'logistics _ Company') VALUES ('$ maxnum ', '$ or_id', '$ or_it', '$ shipment',' $ payments_date ',' $ buyer_email ',' $ buyer_name ',' $ buyer_phone ',' $ sku ', '$ j_sku', '$ product_name', '$ quantity', '$ recipient_name', '$ ship_address1', '$ ship_address2', '$ ship_address3', '$ ship_state ', '$ ship_postal', '$ ship_country', '$ zhanghao', '$ ship_city', '$ cancel_order', '$ delivery_areas', '$ logistics_number', '$ logistics_company ') ";
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.