Hi,
I have a Cron Job which partially works. However whatever method I try to add or change columns stops the code from working.
Can anyone advise how I bug fix or make changes to the code. Whather I try doesn’t work.
I have 13 question marks but whenever I add a remove a field and quetion mark it stops working.
$sth = $dbh->prepare('INSERT INTO `productdbase`
(`product_id`, `link`, `name`, `linkname`, `fulldescription`, `image_link`, `rrp`, `sell_price`, `discount`, `merchant`, `furniture_group`)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE `link` = ?, `fulldescription` = ?, `rrp` = ?, `sell_price` = ?, `discount` = ?, `furniture_group` = ?');
$sth_fg = $dbh->prepare('INSERT INTO `furniture_groups`
(`long_name`, short_name)
VALUES(?, ?)');
// -----------------------------------------------------------
// Loop through the XML structure
// ----
$dbh->beginTransaction();
$m = 1;
foreach($xml->merchant as $merchant) {
$attributes = $merchant->attributes();
$merchant_id = (string)$attributes->id;
$merchant_name = (string)$attributes->merchant;
$merchant_name = (string)$attributes->linkname;
//echo ($m > 1 ? '<br>' : ''), 'New merchant: ', $merchant_name, ' (ID: ', $merchant_id, ')<br>';
foreach($merchant->prod as $product) {
$product_id = (string)$product->attributes()->id;
$product_name = (string)$product->text->name;
$link_name = strtolower(str_replace(array(' ', '_'), '-', preg_replace('#[^A-Za-z0-9 \\-_]#', '', $product_name)));
$product_link = (string)$product->uri->awTrack;
$product_description = (string)$product->text->desc;
//$furniture_type = (string)$product->cat->awCat;
$furniture_group = (string)$product->cat->mCat;
$image_link = (string)$product->uri->awImage;
$merchant = (string)$product->uri->merchant_name;
$recommended_retail_price = (string)$product->price->buynow;
$sell_price = (string)$product->price->buynow;
$price = (string)$product->price->rrp;
$retailprice = (string)$product->price->rrp;
$discount = ($recommended_retail_price * $sell_price > 0 ? round((1 - $sell_price / $recommended_retail_price) * 100) : 0);
// echo str_repeat(' ', 10), $product_id, '<br>';
// echo str_repeat(' ', 17), $product_name, '<br>';
// echo str_repeat(' ', 17), $product_link, '<br>';
// echo str_repeat(' ', 17), str_replace(' ', '<br>' . str_repeat(' ', 17), $product_description), '<br>';
// echo str_repeat(' ', 17), $furniture_type, '<br>';
// echo str_repeat(' ', 17), $product_category, '<br>';
// echo str_repeat(' ', 17), $image_link, '<br>';
// echo str_repeat(' ', 17), $recommended_retail_price, '<br>';
// echo str_repeat(' ', 17), $sell_price, '<br>';
try {
$sth->execute(array(
$product_id,
$product_link,
$product_name,
$link_name,
$product_description,
$image_link,
$recommended_retail_price,
$sell_price,
$discount,
$merchant_name,
$furniture_group,
$product_link,
$product_description,
$recommended_retail_price,
$sell_price,
$discount,
$furniture_group