New Zenner
- Join Date:
- Jan 2010
- Location:
- SoCal
- Posts:
- 47
- Plugin Contributions:
- 0
Blank Page on "Add to Cart" - Call to Undefined Function zen_create_random_value
My zencart store appears to be having a problem since upgrading to 1.5.1 (from 1.5.0), during the time when someone adds a product to the cart. They get the Error 500 or just a blank page when clicking "add to cart".
My debug log issued me the following:
[04-Oct-2012 09:59:28] PHP Fatal error: Call to undefined function zen_create_random_value() in /hsphere/local/home/user/prettygirlygirl.com/includes/classes/shopping_cart.php on line 1295
I used the following page to find out more where the zen_create_random_value is called and/or referenced
http://phpxref.com/xref/zencart/_functions/zen_create_random_value.html
Of the 2 files listed here that are believed to define the zen_create_random_value function, the functions_general.php (in /includes/functions/) is the one where zen_create_random_value seems to be absent. I did a check in the 1.5.0 site files to check for it there and there it was. On lines 614 to 634 of /includes/functions/functions_general.php (of the 1.5.0 version of Zencart), it reads:
function zen_create_random_value($length, $type = 'mixed') {
if ( ($type != 'mixed') && ($type != 'chars') && ($type != 'digits')) return false;
$rand_value = '';
while (strlen($rand_value) < $length) {
if ($type == 'digits') {
$char = zen_rand(0,9);
} else {
$char = chr(zen_rand(0,255));
}
if ($type == 'mixed') {
if (preg_match('/^[a-z0-9]$/i', $char)) $rand_value .= $char;
} elseif ($type == 'chars') {
if (preg_match('/^[a-z]$/i', $char)) $rand_value .= $char;
} elseif ($type == 'digits') {
if (preg_match('/^[0-9]$/', $char)) $rand_value .= $char;
}
}
return $rand_value;
}
I could not find anyone on here who is having this problem in 1.5.1 so I figured I would ask here. When I "add to cart" and get the blank page, I can sometimes reload the page and then I am taken to the shopping carts contents page. I clicked "checkout" and did not get a blank page again but I have not tried to complete the checkout process. On the shopping carts content page, any attempt to change the quantity and press the refresh button next to it also results in this blank page.