0
votes

Just downloaded latest files from https://github.com/consolibyte/quickbooks-php and setup on localhost and its working perfectly web connector sample with QuickBooks desktop, but when uploaded to server even sample form is not running throwing error, please review following form.

https://qbdesktop.1dash.com/consus/webconnector/form.php

Throwing following message.

Warning: array_merge(): Argument #2 is not an array in consus/QuickBooks/Utilities.php on line 54

Notice: Undefined index: pass in consus/QuickBooks/Utilities.php on line 57

Warning: require_once(consus/QuickBooks/Driver/.php): failed to open stream: No such file or directory in consus/QuickBooks/Loader.php on line 56

Fatal error: require_once(): Failed opening required 'consus/QuickBooks/Driver/.php' (include_path='.:/usr/share/pear:/usr/share/php:/var/www/html/consus') in consus/QuickBooks/Loader.php on line 56

following is code in config.php

    <?php
    // We need to make sure the correct timezone is set, or some PHP installations will complain
    if (function_exists('date_default_timezone_set'))
    {
        // * MAKE SURE YOU SET THIS TO THE CORRECT TIMEZONE! *
        // List of valid timezones is here: http://us3.php.net/manual/en/timezones.php
        date_default_timezone_set('America/New_York');
    }

    // I always program in E_STRICT error mode... 
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(E_ALL | E_STRICT);

    // Require the framework
    require_once dirname(__FILE__) . '/../QuickBooks.php';

    // Your .QWC file username/password
    $qbwc_user = 'quickbooks';
    $qbwc_pass = 'password';

    // * MAKE SURE YOU CHANGE THE DATABASE CONNECTION STRING BELOW TO A VALID MYSQL USERNAME/PASSWORD/HOSTNAME *
    //$dsn = 'mysql://root@localhost/1dashnew';
    $dsn = 'mysql://user:[email protected]:3306/dbname';

    if (!QuickBooks_Utilities::initialized($dsn))
    {
        // Initialize creates the neccessary database schema for queueing up requests and logging
        QuickBooks_Utilities::initialize($dsn);

        // This creates a username and password which is used by the Web Connector to authenticate
        QuickBooks_Utilities::createUser($dsn, $qbwc_user, $qbwc_pass);

        $Queue = new QuickBooks_WebConnector_Queue($dsn);
        // Create our test table
        mysql_query("CREATE TABLE my_customer_table (
          id int(10) unsigned NOT NULL AUTO_INCREMENT,
          name varchar(64) NOT NULL,
          fname varchar(64) NOT NULL,
          lname varchar(64) NOT NULL,
          quickbooks_listid varchar(255) DEFAULT NULL,
          quickbooks_editsequence varchar(255) DEFAULT NULL,
          quickbooks_errnum varchar(255) DEFAULT NULL,
          quickbooks_errmsg varchar(255) DEFAULT NULL,
          PRIMARY KEY (id)
        ) ENGINE=MyISAM");
    }

and in handler.php

<?php
/**
 * Require some configuration stuff
 */ 
require_once dirname(__FILE__) . '/config.php';

// Handle the form post
if (isset($_POST['submitted']))
{
    // Save the record
    mysql_query("
        INSERT INTO
            my_customer_table
        (
            name, 
            fname, 
            lname
        ) VALUES (
            '" . mysql_escape_string($_POST['name']) . "', 
            '" . mysql_escape_string($_POST['fname']) . "', 
            '" . mysql_escape_string($_POST['lname']) . "'
        )");

    // Get the primary key of the new record
    $id = mysql_insert_id();

    // Queue up the customer add 
    $Queue = new QuickBooks_WebConnector_Queue($dsn);
    $Queue->enqueue(QUICKBOOKS_ADD_CUSTOMER, $id);

    die('Great, queued up a customer!');
}
1
Post your code. Particularly your $dsn string.Keith Palmer Jr.
code added, please help me to figure this outmhkhalil

1 Answers

1
votes

Looking at the code generating the error message:

https://github.com/consolibyte/quickbooks-php/blob/master/QuickBooks/Utilities.php#L54

    $parse = array_merge($defaults, parse_url($dsn));

    $parse['user'] = urldecode($parse['user']);
    $parse['pass'] = urldecode($parse['pass']);

The only way you could be seeing this error message is if your $dsn string is incorrectly formatted.

I would bet anything that this isn't your actual $dsn string:

$dsn = 'mysql://user:[email protected]:3306/dbname';

And that if you posted your actual $dsn string, it would not be correctly formatted.

Please either post it, or double-check it on your end and make sure it matches the correct format. Make sure that if you have special characters in there, you URL encode them as required.