justlukeyou Posted May 22, 2012 Share Posted May 22, 2012 Hi, I am trying to add two new category feeds into my database using a cron job however it is telling that: Unknown column 'merchant_category' in 'field list'. The inputs and the column names are: category_name merchant_category The problem is I dont actually know what the field list is $prod = new SimpleXMLElement($domString); $id = $prod->attributes(); $id = $id['id']; $link = $prod->uri->mLink; $description = mysql_real_escape_string($prod->text->name); $fulldescription = mysql_real_escape_string($prod->text->desc); $category_name = mysql_real_escape_string($prod->text->desc); $merchant_category = mysql_real_escape_string($prod->text->desc); $image = $prod->uri->awImage; $retailprice = $prod->price->rrp; $sellprice = $prod->price->buynow; if($id) { if($sellprice > 0 && $retailprice > 0) { $discount = 100 - ($sellprice / $retailprice * 100); } else { $discount = 0; } echo "New product: #" . $id . " - " . $category_name . " . $merchant_category ." . $description . " - Discount: " . $discount . "%" . (($discount > 90.01 || $discount < 0) ? " (Not inserted)" : " (Inserted)") . "<br />" . $fulldescription . "<br /><br />"; if($discount > 0 && $discount < 90.01) { $query = mysql_query("SELECT * FROM productdbasetest WHERE id = '".$id."'"); if(mysql_num_rows($query) > 0) { $query = mysql_query("UPDATE productdbasetest SET category_name = '".$category_name."', merchant_category = '".$merchant_category."', awImage = '".$image."', link = '".$link."', description = '". $description."', fulldescription = '".$fulldescription."', price = '".$sellprice."', discount = '".round($discount)."', merchant = '".$merchant."' WHERE id = '".$id."'"); } else { $query = mysql_query("INSERT INTO productdbasetest (id, category_name, merchant_category, awImage, link, description, fulldescription, price, discount, merchant) VALUES ('".$id."', '".$category_name."', '". $merchant_category."', '".$image."', '".$link."', '".$description."', '".$fulldescription."', '".$sellprice."', '".round ($discount)."', '".$merchant."')"); Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted May 22, 2012 Share Posted May 22, 2012 That error means you do not have a column 'merchant_category' in your 'productdbasetest' table. Quote Link to comment Share on other sites More sharing options...
justlukeyou Posted May 22, 2012 Author Share Posted May 22, 2012 Brilliant thanks, When I run the job nothing enters when I use the following: $category_name = $prod->uri->category_name; $merchant_category = $prod->uri->merchant_category; But I thought that this mean that the input is the same as my column names. For example with this one I am changing the input from image to 'awImage' $image = $prod->uri->awImage; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.