469,086 Members | 1,287 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,086 developers. It's quick & easy.

undefined offset 1 and 2 on line 5 and 6 in cart.tpl

1
Hi,

I'm getting the error:

undefined offset 1 on line 5 of cart.tpl and undefined offset 2 on line 6 of cart.tpl.

The lines in this file are:

Expand|Select|Wrap|Line Numbers
  1. 1 <?php
  2. 2
  3. 3    preg_match('#^(.*) - ([^ ]*)$#i', $text_items, 4 $matches);
  4. 4    
  5. 5    $count = $matches[1];
  6. 6    $total = $matches[2];
  7. 7
  8. 8 ?>
Any idea what goes wrong and how I can fix this?

Thnx for your help!
Nov 18 '12 #1
1 2123
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code.

That means that the preg_match found no matches. And therefore there is no index 1 or 2. You should check first that there are matches before trying to retrieve the matches.
Nov 19 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by lawrence | last post: by
2 posts views Thread by Steven | last post: by
4 posts views Thread by Richard Lawrence | last post: by
3 posts views Thread by delusion7 | last post: by
9 posts views Thread by simple12 | last post: by
2 posts views Thread by neridaj | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by kglaser89 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.