刚从https://github.com/consolibyte/quickbooks-php上下载了最新的文件,安装在本地主机上,它的web连接器完全可以用QuickBooks桌面连接,但是当上传到服务器时,即使是样例表单也没有运行抛出错误,请查看下面的表单。
https://qbdesktop.1dash.com/consus/webconnector/form.php
抛出下面的信息。
警告: array_merge():参数#2不是第54行consus/QuickBooks/Uutities.php中的数组 注意:未定义索引:在第57行的consus/QuickBooks/Uutities.php中传递 警告:require_once(consus/QuickBooks/Driver/..php):未能打开流:在第56行的consus/QuickBooks/Loader.php中没有这样的文件或目录 致命错误:(include_path='.:/usr/share/pear:/usr/share/php:/var/www/html/consus') /QuickBooks/Loader.php第56行中的require_once():打开失败需要‘consus/QuickBooks/Driver/..php’
以下是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");
}在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!');
}发布于 2017-09-05 00:37:42
查看生成错误消息的代码:
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']);看到此错误消息的唯一方法是,如果您的$dsn字符串格式不正确。
我敢打赌,这不是真正的$dsn字符串:
$dsn = 'mysql://user:password@server.amazonaws.com:3306/dbname';而且,如果您发布了实际的$dsn字符串,则不会正确格式化它。
请张贴它,或重复检查它在你的一端,并确保它符合正确的格式。确保如果您有特殊的字符在那里,您的URL编码他们的需要。
https://stackoverflow.com/questions/42340733
复制相似问题