Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Error in cc_validation.php


Recommended Posts

Every time I attempt to process a credit card, I get an error:

Parse error: parse error, unexpected T_ELSE in /httpd/local/home/server/includes/classes/cc_validation.php on line 35


which is followed by an error in the pm2checkout.php (which is caused by the first error)


Line 35 is:


} else { statement just before


$this->cc_type = 'Unknown';



in the code below but I haven't been able to figure out the parse error. If I remove


} else {

$this->cc_type = 'Unknown';


all together, then the process continues fine but

I hate to lop off code if it was there for a purpose.


    function validate($number, $expiry_m, $expiry_y) {
     $this->cc_number = ereg_replace('[^0-9]', '', $number);

     if (ereg('^4(.{12}|.{15})$', $this->cc_number)) { 
       $this->cc_type = 'Visa'; 
     } elseif (ereg('^5[1-5].{14}$', $this->cc_number)) { 
       $this->cc_type = 'Master Card'; 
     } elseif (ereg('^3[47].{13}$', $this->cc_number)) { 
       $this->cc_type = 'American Express'; 
     } elseif (ereg('^3(0[0-5].{11}|[68].{12})$', $this->cc_number)) { 
       $this->cc_type = 'Diners Club'; 
     } elseif (ereg('^6011.{12}$', $this->cc_number)) { 
       $this->cc_type = 'Discover'; 
     } elseif (ereg('^(3.{15}|(2131|1800).{11})$', $this->cc_number)) { 
       $this->cc_type = 'JCB'; 
     } elseif (ereg('^5610.{12}$', $this->cc_number)) { 
       $this->cc_type = 'Australian BankCard'; 
     } else { 
       $this->cc_type = 'Unknown'; 
     } else {
       return -1;


Can anyone see the problem with this code? I could use some additional eyes cause these old ones of mine just aren't picking out the problem.




"It's a small world...

But I wouldn't want to paint it!"

Stephen Wright

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...