I think you are trying to use this line of code inside a function, but forgot to make $db global.
like:
PHP Code:global $db;
I think you are trying to use this line of code inside a function, but forgot to make $db global.
like:
PHP Code:global $db;
Thanks for that.
I now get an error
1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Object' at line 1
in:
[Object]
PHP Code:if (zen_not_null(POINTS_AUTO_EXPIRES)){
global $db;
$points_query = $db->Execute("SELECT customers_shopping_points FROM " . TABLE_CUSTOMERS . " WHERE customers_id = '" . (int)$id . "' AND customers_points_expires > CURDATE() LIMIT 1");
} else {
$points_query = $db->Execute("SELECT customers_shopping_points FROM " . TABLE_CUSTOMERS . " WHERE customers_id = '" . (int)$id . "' LIMIT 1");
}
$points = $db->Execute($points_query);
return $points['customers_shopping_points'];
}
try using the global Outside the if statement
Zen cart PCI compliant Hosting
Hi Merlin,
I tried that first time around adding it to the top of the file.
If I do that I get the same fatal error
Fatal error: Call to a member function on a non-object
Feeling much fresher today but cant figure this out for the life of mePHP Code:if (zen_not_null(POINTS_AUTO_EXPIRES)){
$points_query = $db->Execute("SELECT customers_shopping_points FROM " . TABLE_CUSTOMERS . " WHERE customers_id = '" . (int)$id . "' AND customers_points_expires > CURDATE() LIMIT 1");
} else {
$points_query = $db->Execute("SELECT customers_shopping_points FROM " . TABLE_CUSTOMERS . " WHERE customers_id = '" . (int)$id . "' LIMIT 1");
}
![]()
ahhhhh the wonders of coca cola ;)
Ive figured it out, theres not meant to be any _query on any of the queries so...
if (zen_not_null(POINTS_AUTO_EXPIRES)){
$points_query = $db->Execute("SELECT customers_shopping_points FROM " . TABLE_CUSTOMERS . " WHERE customers_id = '" . (int)$id . "' AND customers_points_expires > CURDATE() LIMIT 1");
} else {
$points_query = $db->Execute("SELECT customers_shopping_points FROM " . TABLE_CUSTOMERS . " WHERE customers_id = '" . (int)$id . "' LIMIT 1");
}
Isnt meant to be there.
![]()
Note: this line ...
Might result in a better answer if you use:PHP Code:return $points['customers_shopping_points'];
PHP Code:return $points->fields['customers_shopping_points'];
Linda McGrath
If you have to think ... you haven't been zenned ...
Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!
Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here
Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!
Thanks to Ajeh for the pointer...
In the end my cola power cotton wool fueled head decided to check how another file does this and finally came up with the following ...
PHP Code:if (zen_not_null(POINTS_AUTO_EXPIRES)){
global $db;
$points_query = "SELECT customers_shopping_points FROM " . TABLE_CUSTOMERS . " WHERE customers_id = '" . (int)$id . "' AND customers_points_expires > CURDATE() LIMIT 1";
} else {
$points_query = "SELECT customers_shopping_points FROM " . TABLE_CUSTOMERS . " WHERE customers_id = '" . (int)$id . "' LIMIT 1";
}
$points = $db->Execute("$points_query");
return $points->fields['customers_shopping_points'];
}