我想将信息输入到数据库中,并且遇到了一个问题,我确信我只是犯了一个简单的错误。要更新我正在使用的表格:将数据从数组输入到数据库中
$conn->query("update webPrice set price= " . $amazonResult['price'] . " where asin = '" . $amazonResult['asin'] . "'");
$ conn是我的连接。价格始终输入为0.我知道那里有信息,因为当我执行print_r($ amazonResult)时,我看到了我想要插入到数据库中的所有内容。代码来获得亚马逊的信息是:
foreach($parsed_xml->GetMyPriceForASINResult as $item) {
$asin2 =$item->attributes()->ASIN;
$current = $item->Product;
$status = $item->attributes()->status;
if (stristr($status, "Success") == true)
{
$amazonResult = array(
'asin' => $asin2,
'price' => $current->Offers->Offer->BuyingPrice->ListingPrice,//AttributeSets->children('ns2', true)->
);
我认为这个问题是我的更新语句,但我的不知道它是什么。 asin信息输入正确。这些字段是price = double和asin = varchar。
编辑:这里是print_r($ amazonResult)的结果;
Array ([asin] => SimpleXMLElement Object ([0] => 0176055452) [price] => SimpleXMLElement Object ([CurrencyCode] => USD [Amount] => 10.11))
谢谢我刚刚试过你的建议,并得到相同的结果。 – Jim
编辑我的答案,根据问题中的编辑。看一看。 –
我知道这会很简单。谢谢,这很好。 – Jim