consolibyte / quickbooks-php

QuickBooks Integration for PHP
Eclipse Public License 1.0
457 stars 338 forks source link

getLastError():: Blank #251

Closed clrncmcnlsn closed 5 years ago

clrncmcnlsn commented 5 years ago

image

Inside our quickbooks_queue table are some data that have q statuses that change to i when updated via the Web Connector app.

What does the status i mean? The msg column changes from NULL to a blank. As shown on the image above, getLastError() is also blank.

QWCLog.txt ends with this message:

UpdateThisScheduledApp() : QBWC1031: Update completed with some error. Application has been notified of the error accordingly. See QWCLog for further information.
consolibyte commented 5 years ago

The i status is for in progress.

Generally, nothing should stay in that status. Something in that status generally indicates you have an error in your PHP or SQL. Did you check your PHP error log?

clrncmcnlsn commented 5 years ago

It turned out that there was some typo in the query statement which has already been fixed.

function _quickbooks_invoice_add_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale){
    $con = mysqli_connect(--OMMITTED--);

    if(mysqli_connect_errno())
    {
        echo 'Failed to connect: '.mysqli_connect_error();
    }

    $sales = mysqli_fetch_assoc(mysqli_query($con, 'SELECT qty_sold, sales_price from sales where id = ' . $ID ));

        $customer = mysqli_fetch_assoc(mysqli_query($con, 'SELECT company from accounts where id in(select account_id from customers where id in(select customer_id from sales where id = '. (int) $ID .'))'));

    $species = mysqli_fetch_assoc(mysqli_query($con, 'SELECT name from species where id in (select species_id from sales_species where sales_id =' . $ID . ')'));

    $xml = '<?xml version="1.0" encoding="utf-8"?>
            <?qbxml version="2.0"?>
            <QBXML>
                <QBXMLMsgsRq onError="continueOnError">
                    <InvoiceAddRq requestID="'. $requestID .'">
                        <InvoiceAdd>
                            <CustomerRef>
                                <FullName>'. $customer['company'] .'</FullName>
                            </CustomerRef>
                            <TemplateRef>
                                <FullName>Intuit Service Invoice</FullName>
                            </TemplateRef>
                            <InvoiceLineAdd>
                                <ItemRef>
                                    <FullName>'. $species['name'] .'</FullName>
                                </ItemRef>
                                <Quantity>'. $sales['qty_sold'] .'</Quantity>
                                <Rate>'. $sales['sales_price'] .'</Rate>
                            </InvoiceLineAdd>
                        </InvoiceAdd>
                    </InvoiceAddRq>
                </QBXMLMsgsRq>
            </QBXML>';
}

I tested the queries separately which returned correct results, but I still get the blank getLastError(). PHP logs didn't show any errors.

clrncmcnlsn commented 5 years ago

It's the return $xml statement that was missing! :finnadie: