PHP mysqli为一个插入添加多个条目

时间:2015-07-13 05:50:54

标签: php database mysql

以下简短的PHP代码应该在数据库表中添加1个条目。但是当我运行这个时,我发现了3个相同的条目 MySQL服务器版本:5.5.39 - MySQL社区服务器

PHP / 5.4.31

<?PHP
// connect to temp DB
$db_host = "localhost";
$db_username = "root";
$db_password = "";
$db_name = "tempdb";

// Create connection
$conn = new mysqli($db_host, $db_username, $db_password, $db_name);
if ($conn->connect_error)
   {  die("Connection failed: " . $conn->connect_error);  }
$mysqlstr = "    INSERT INTO 
    tempproduct (
        `productName`, `MerchantID`,  `Merchant`, `myLink`, `Thumbnail`, 
        `BigImage`, `Price`, `RetailPrice`, `Category`, `Subcategory`, 
        `Description`, 
        `Custom1`, `Custom2`, `Custom3`, `Custom4`,  `Custom5`, 
        `Lastupdated`, `productStatus`, `Manufacturer`, 
        `PartNumber`, `MerchantCategory`, `MerchantSubcategory`, 
        `ShortDescription`, 
        `ISBN`, `UPC`, `SKU`, `CrossSell`, 
        `MerchantGroup`, `MerchantSubgroup`, `CompatibleWith`, 
        `CompareTo`, `QuantityDiscount`, `Bestseller`, `AddToCartURL`, 
        `ReviewsRSSURL`, `Option1`, `Option2`, `Option3`, `Option4`, 
        `Option5`, `MobileURL`, `MobileImage`, `MobileThumbnail`
    ) 
    VALUES(
         'Fossil Editor Leather Ladies Watch ES3242', '32800', 'Pricefalls.com',  '[some url]', '[some url]', 
         '[some url]', '113.10', '145', 'Fashion', 'Jewelry', 
         'Stainless steel case. White leather strap. White dial. Day date and 24-hour time. Quartz movement. Water resistant 50 meters. Case 38mm. Buckle closure.', 
         'Silver', 'Stainless Steel', '', '38', 'female', 
         '2015-06-24 14:21:30',  'instock', 'Fossil', 
         'ES3242', 'Jewelry & Watches', 'Watches', 
         'Stainless steel case. White leather strap. White dial. Day date and 24-hour time. Quartz movement. Water resistant 50 meters. Case 38mm. Buckle closure.', 
         '', '691464976040', '4907551', '', '', '', '', '', '', 
         '0', '', '', '', '', '', '', '', '', '', ''
    )";
mysqli_query($conn,$mysqlstr);
// $conn->query($mysqlstr);
  echo "done";
 $conn->close();
?>

0 个答案:

没有答案