Hi,

Assuming your code algorithm is okay (although some named
constants or comments might be nice)...  if you are using
both warnings and the 'use strict' pragma then most errors
become obvious.

> while (@row = $sth2->fetchrow_array && $done == 0)

while (@row = $sth2->fetchrow_array() and $done == 0)


You've used a flag variable to exit the loop, what is wrong
with a 'last' statement?  I'd code that as:

while ($sth2->fetchrow_array) {

  # Useful comment
  if ($row[0] == $pid and $row[1] == 1) {
    print qq~Product has been sold already, select a
different product.\n~;
  }

  # Useful comment
  else { 
    print qq~Item $pid has been placed in your shopping
cart. <A HREF = "viewcart.pl">CLICK HERE TO VIEW CART
CONTENTS</A>\n~;
  }
}

You are breaking the loop early, since $done always gets
set to 1 in a single iteration.  My nicer version avoids
the need for that variable.  Enjoy!

Jonathan Paton




__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page from News and Sport to Email and Music 
Charts
http://uk.my.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to