自从我成为一名编码员以来已经有很长一段时间了,我正在准备一些我知道非常简单的东西。
我正在尝试访问产品的 XML 页面并将它们插入到我的数据库中。
我生成的代码给了我以下错误消息:
Unknown column '10074' in 'field list'
10074 是第一项的产品 ID。
代码如下。
你能指出我正确的方向吗,因为它真的很接近我。
提前谢谢了!
<?php
$Products = simplexml_load_file('http://atsdistribution.co.uk/feeds/xml_all_products.aspx');
$con = mysql_connect(*****);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("catflaps_products", $con);
foreach($Products->Product as $Product)
{
$ProductID = $Product->ProductID;
$Name = $Product->Name;
$DropshipPrice = $Product->DropshipPrice;
$SRP = $Product->SRP;
$Brand = $Product->Brand;
$Xline = $Product->Xline;
$InStock = $Product->InStock;
$Stock = $Product->Stock;
$Barcode = $Product->Barcode;
$Weight = $Product->Weight;
$CategoryID = $Product->CategoryID;
$Category = $Product->Category;
$SmallImage = $Product->SmallImage;
$LargeImage = $Product->LargeImage;
$Description = $Product->Description;
mysql_query("INSERT INTO test(ProductID, Name, DropshipPrice, SRP, Brand, Xline, InStock, Stock, Barcode, Weight, CategoryID, Category, SmallImage, LargeImage, Description)
VALUES(`$ProductID`, `$Name` , `$DropshipPrice`, `$SRP`, `$Brand`, `$Xline`, `$InStock`, `$Stock`, `$Barcode`, `$Weight`, `$CategoryID`, `$Category`, `$SmallImage`, `$LargeImage`, `$Description`)")
or die(mysql_error());
}
mysql_close($con);
// some code
?>