Server OS: Linux 3.16.0-5-amd64
Database: MySQL 5.6.39-1~dotdeb+7.1
HTTP Server: Apache/2.4.10 (Debian) mod_fastcgi/mod_fastcgi-SNAP-0910052141 mod_fcgid/2.3.9 PHP/5.6.33-0+deb8u1 mod_python/3.3.1 Python/2.7.9 OpenSSL/1.0.1t
PHP Version: 5.6.33-0+deb8u1 (Zend: 2.6.0)
So I'm updating some custom code. This code is supposed to read values off a "master" database and then update it's own database with it. That part works fine. When I add a new product into my "master" zen-cart it is supposed to populate the "clone" sites but it never applies the markup. I need to change the code to start applying a markup/rounding to the prices in order to keep everything current.
But after adding the new code I'm throwing this error:
] mod_fcgid: stderr: PHP Notice: Undefined variable: db in admin clone site/index.php on line 21, referer: admin clone site/login.php
] mod_fcgid: stderr: PHP Fatal error: Call to a member function Execute() on null in admin clone site/index.php on line 21, referer: admin clone site/login.php
(i've cleaned them up)
And it's only throwing this error on the site that has the new code.
PHP Code:
$sql_date = $db->Execute("SELECT products_last_modified FROM " . TABLE_PRODUCTS . " WHERE 1 ORDER BY RAND() LIMIT 1;");
$date = strtotime($sql_date->fields['products_last_modified']);
if(($date + 43200) < time())
{
$update_sql = "INSERT INTO products SELECT * FROM foreverpets.products
ON DUPLICATE KEY UPDATE
products_price_w=VALUES(products_price),
products_status=VALUES(products_status),
products_last_modified = NOW();";
$db->Execute($update_sql);
/* MAB add update price with markup */
$markup = $db->Execute("SELECT configuration_value FROM configuration WHERE configuration_key = STORE_MARKUP;");
$rounding = $db->Execute("SELECT configuration_value FROM configuration WHERE configuration_key = STORE_ROUNDING;");
switch ($rounding)
{
case 1: //no rounding
$prices_sql = "UPDATE products
SET products_price=TRUNCATE((products_price_w * " . ($markup + 1) . "), 2);";
break;
case 2: //nearest $0.99
$prices_sql = "UPDATE products
SET products_price=((TRUNCATE((products_price_w * " . ($markup + 1) . "), 0)) - 0.01)+1;";
break;
case 3: //nearest $1.00
$prices_sql = "UPDATE products
SET products_price=TRUNCATE((products_price_w * " . ($markup + 1) . "), 0)+1;";
break;
}
$db->Execute($prices_sql);
}
New code is after/*MAB
This manifests as a HTTP error 500.
Any help would be greatly appreciated, I now this isn't a Zen Cart issue.
Bookmarks