doz59484 2017-02-20 09:26
浏览 87

QuickBooks Web连接器(Php)array_merge():参数#2不是第54行的... / QuickBooks / Utilities.php中的数组

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:password@server.amazonaws.com: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条回答 默认 最新

  • douzhuangna6906 2017-09-05 00:37
    关注

    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:password@server.amazonaws.com: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.

    评论

报告相同问题?

悬赏问题

  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机