我想將信息輸入到數據庫中,並且遇到了一個問題,我確信我只是犯了一個簡單的錯誤。要更新我正在使用的表格:將數據從數組輸入到數據庫中
$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