sub show_cart { my $dbh = DBI->connect("DBI:mysql:xxx:xxxxx", "xx", "xx") || die $DBI::errstr; my $sth = $dbh->prepare( "SELECT id, prod_id, qty from cart where cookie = ?") || die $DBI::errstr; $sth->execute($cart_id) || die $sth->errstr(); print "NO ITEMS IN CART" unless $sth->fetchrow_array(); print $cart_id . '

'; # for testing while (my ($id,$prod_id,$qty) = $sth->fetchrow_array()){ print "====== $id =====
"; # for testing }