in reply to DBI forgets last record

I suspect it's the first one you're losing. You call $sth->fetchrow_array() once to see if anything was found, and throw away the result. Call $sth->rows instead for that test.

Update: In other words:     print 'NO ITEMS IN CART' unless $sth->rows;

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Re: DBI forgets last record
by mpeppler (Vicar) on Jan 09, 2003 at 19:23 UTC
    Beware that $sth->rows() will not work in this case for many (most?) DBI drivers. From "perldoc DBI":
    Generally, you can only rely on a row count after a non-`SELECT' `execute' (for some specific operations like `UPDATE' and `DELETE'), or after fetching all the rows of a `SELECT' statement.

    For `SELECT' statements, it is generally not possible to know how many rows will be returned except by fetching them all. Some drivers will return the number of rows the application has fetched so far, but others may return -1 until all rows have been fetched. So use of the `rows' method or `$DBI::rows' with `SELECT' statements is not recommended.