Can't seem to get this working. Need help to resolve code problem in catalog/includes/functions/general.php To work in new PHP 5.3 former code "ereg" needs to be changed to "preg-match". Changed 2 of the three lines as below: Here is the code: if ($type == 'mixed') { if (preg_match('^[a-z0-9]$', $char)) $rand_value .= $char; } elseif ($type == 'chars') { if (preg_match('^[a-z]$', $char)) $rand_value .= $char; } elseif ($type == 'digits') { if (eregi('^[0-9]$', $char)) $rand_value .= $char; } } But when I change the 3rd one which is "eregi" with the extra "i" to "preg_match" which is suppose to be changed to the same change as "ereg" I get this error: Warning: preg_match() [function.preg-match]: No ending delimiter '^' found in /includes/functions/general.php on line 1043 Appreciate any help to resolve this.
Something like this should work. Looks like you just need the forward slash inside the matching criteria. if (preg_match('/^[a-z0-9]$/', $char)) $rand_value .= $char; } elseif ($type == 'chars') { if (preg_match('/^[a-z]$/', $char)) $rand_value .= $char; } elseif ($type == 'digits') { if (preg_match('/^[0-9]$/', $char)) $rand_value .= $char;
Thank you so much, that worked. I do have a new error I'm stuck on: Warning: preg_replace() [function.preg-replace]: Compilation failed: nothing to repeat at offset 0 in /includes/functions/general.php on line 61 Here is the code: function tep_sanitize_string($string) { $string = preg_replace(' /+/', ' ', trim($string)); return preg_replace("/[<>]/", '_', $string); } Line 61 is in Bold.