>   I am trying to get an invoice and received a message to the following:
> Invoice "92" is an invalid invoice. Click here to return to the list of
> invoices. Query was SELECT i.User, i.Created, u.Address, b.Address FROM
>  invoice i, user u, shipping b WHERE i.ID = 92 AND b.Invoice = 92 AND
>  i.User = u.ID AND i.Active = 'Y'
>  I require that people register for the site to buy things.
> Can you tell me where I can find out more about this error? I have had
> it a few times and thought that maybe it was the end user that was
screwing
> up, but I think it might be the program. It could be that it is an old
> version of FreeTrade that I am using?
> Any help is appreciated.  Especially help on how I can get rid of this
error.

I have two comments.

First, it looks like edit_invoice is not allowing anyone to edit invoices
that weren't created by registered users.  We'll have to deal with that.  I
know we fixed for a live site.

Second, let's take as a given that users have to register in order to
checkout.
How can this query fail?  Probably because there's a missing billing record.
I have seen this happen before.  We think it happens when people start
hitting
the back button.  That's why I added the code that sends expiration headers.
Still, I think some browsers ignore these headers.  Either that or people
are
using two browsers to purposely mess things up.

Another bit of code I've added to deal with this goes into SUBMIT_ORDER
(below).
This check is done before setting the invoice active.  Hopefully you will
never
have a client confirming an order that doesn't have all it's parts.  I
neglected
to commit this code until now.  I know we're all busy, but it would be
really
helpful if everyone could try to inspect the order processing code and dream
up
ways that it could fail, even if it seems impossible.

        /* make sure this invoice has:
        **      1. A billing record with matching address record
        **      2. At least one invoice_sku record
        **      3. At least one shipping record with matching address record
        **
        ** The intention is to avoid those cases where the user uses the
        ** back button to screw up the order, then somehow returns to the
        ** order_confirm screen and clicks submit.  Yes, these three queries
        ** are expensive, but unfortunately necessary.
        */
        if($ContinueProcessing)
        {
                //billing record
                $Query = "SELECT Address ";
                $Query .= "FROM billing b, address a ";
                $Query .= "WHERE b.Invoice=$invoice ";
                $Query .= "AND b.Address = a.ID ";
                $DatabaseResult = mysql_query($Query, $DatabaseLink);
                if(!$DatabaseResult OR (mysql_num_rows($DatabaseResult) <= 0))
                {
                        $ActionResults .= "Your invoice is missing billing 
information!<BR>";
                        $SCREEN = "order_info";
                        $ContinueProcessing = FALSE;
                }
        }

        if($ContinueProcessing)
        {
                //invoice_sku
                $Query = "SELECT ID ";
                $Query .= "FROM invoice_sku ";
                $Query .= "WHERE Invoice=$invoice ";
                $DatabaseResult = mysql_query($Query, $DatabaseLink);
                if(!$DatabaseResult OR (mysql_num_rows($DatabaseResult) <= 0))
                {
                        $ActionResults .= "Your invoice has no items!<BR>";
                        $SCREEN = "order_info";
                        $ContinueProcessing = FALSE;
                }
        }

        if($ContinueProcessing)
        {
                //shipping record
                $Query = "SELECT Address ";
                $Query .= "FROM shipping s, address a ";
                $Query .= "WHERE s.Invoice=$invoice ";
                $Query .= "AND s.Address = a.ID ";
                $DatabaseResult = mysql_query($Query, $DatabaseLink);
                if(!$DatabaseResult OR (mysql_num_rows($DatabaseResult) <= 0))
                {
                        $ActionResults .= "Your invoice is missing shipping 
information!<BR>";
                        $SCREEN = "order_info";
                        $ContinueProcessing = FALSE;
                }
        }



------------------------------------------------------------
To subscribe:    [EMAIL PROTECTED]
To unsubscribe:  [EMAIL PROTECTED]
Site:            http://www.working-dogs.com/freetrade/
Problems?:       [EMAIL PROTECTED]

Reply via email to