Administrator
- Join Date:
- Feb 2006
- Posts:
- 10,620
- Plugin Contributions:
- 212
Administrator
Zen Follower
function mysql_escape_string_array(&$var, $db) {
if (is_array($var)) {
array_walk($var,'mysql_escape_string_array', $db);
} else {
$var=mysqli_real_escape_string($db,$var); // This function is deprecated. PHP>=4.3.0 may use mysql_real_escape_string
}
return $var;
} function & query($sql) {
$this->dbConn = mysqli_connect($this->host, $this->dbUser, $this->dbPass, $this->dbName);
if (!$queryResource=mysqli_query($this->dbConn,$sql)) {
trigger_error ('Query failed: '.mysqli_error($this->dbConn).' SQL: '.$sql);
}
return new MySQLResult($this,$queryResource);
}
}Administrator
Zen Follower
Totally Zenned
wolfderby:
so I'm trying to update this add-on but I need a little help getting the admin page registration working but possibly more importantly this error sorted out to make sure it'll all be worth it:
[07-Jan-2018 01:27:35 America/New_York] Request URI: /spelL-MUd-shoRe/qbi_config.php, IP address: 73.52.227.139
#1 mysqli_real_escape_string() called at [/home/content/62/5902262/html/MY_ADMIN/includes/functions/qbi_functions.php:152]
#2 mysql_escape_string_array()
#3 array_walk() called at [/home/content/62/5902262/html/MY_ADMIN/includes/classes/qbi_classes.php:2610]
#4 Proc_form->proc_cleanData() called at [/home/content/62/5902262/html/MY_ADMIN/qbi_config.php:30]
[08-Jan-2018 15:36:37 America/New_York] PHP Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, string given in /home/content/62/5902262/html/MY_ADMIN/includes/functions/qbi_functions.php on line 154
here's the guilty function:
function mysql_escape_string_array(&$var, $db) { if (is_array($var)) { array_walk($var,'mysql_escape_string_array', $db); } else { $var=mysqli_real_escape_string($db,$var); // This function is deprecated. PHP>=4.3.0 may use mysql_real_escape_string } return $var; }
if I switch it to mysql_real_escape_string( and swap the order of the parameters as needed) it php errors about $db not being a resource.
I don't quite understand constructors or classes at this point in my programming experience but this qbi_mysql.php file contains this:
function & query($sql) { $this->dbConn = mysqli_connect($this->host, $this->dbUser, $this->dbPass, $this->dbName); if (!$queryResource=mysqli_query($this->dbConn,$sql)) { trigger_error ('Query failed: '.mysqli_error($this->dbConn).' SQL: '.$sql); } return new MySQLResult($this,$queryResource); } }
which might help someone suggest a solution possibly?
Zen Follower
ShopVille:
Is this for QB online or QB desktop ?
Zen Follower
function find_country_id($country_name) {
//$country_name=mysqli_real_escape_string($this->db,$country_name);
//global $db;
//$this->db=$db;
//$this->db=$db;
$country_name=mysql_real_escape_string($country_name,$this->dbConn);
$country_id=0;
$sql="SELECT countries_id FROM ".TABLE_COUNTRIES." WHERE countries_name LIKE '".$country_name."'";
$result=$this->db->query($sql);
if ($row=$result->fetch()) $country_id=$row['countries_id'];
return($country_id);
}Zen Follower
function find_country_id($country_name) {
$country_id=0;
$sql="SELECT countries_id FROM ".TABLE_COUNTRIES." WHERE countries_name LIKE :country_name";
$sql = $db->bindVars($sql, ':country_name', $country_name, 'string');
$result = $db->Execute($sql);
$country_id = $result->fields['countries_id'];
//$result=$this->db->query($sql);
//if ($row=$result->fetch()) $country_id=$row['countries_id'];
return($country_id);
}Totally Zenned
wolfderby:
so after reading more into the database abstraction I'm convinced I need to go this bindVars route... so I'm trying this...
function find_country_id($country_name) { $country_id=0; $sql="SELECT countries_id FROM ".TABLE_COUNTRIES." WHERE countries_name LIKE :country_name"; $sql = $db->bindVars($sql, ':country_name', $country_name, 'string'); $result = $db->Execute($sql); $country_id = $result->fields['countries_id']; //$result=$this->db->query($sql); //if ($row=$result->fetch()) $country_id=$row['countries_id']; return($country_id); }
but it results in...
[08-Jan-2018 22:01:16 America/New_York] PHP Fatal error: Call to a member function bindVars() on a non-object in
Zen Follower
mc12345678:
I don't know if the following is cruel or just enough of a carrot. So, considering the things that have been made available to the function, is there anything in that line that seems undefined? Think beyond what is in the line as something you know/expect.
Now again, regarding the use of mysql_/mysqli_ related functions, these are typically abstracted in the ZC code so that a "common" function name can be used through all versions of ZC and the software still work. A concern I have whether valid or not, is that it appears that the software is written to take a sort of snapshot of the database and hold it in time while processing, as compared to constantly using the data of the current database. While it may not be so important in this particular function of whether to use the class' internal $db or the one that is used throughout the ZC software, there may be instances where an operation is performed on the internal $db in one function the results of which are pulled from another with the expectation that the internal $db data hasn't been modified between the two operations.
It's not something that I necessarily expect, but considering how the internal $db was assigned at one point or another, it seems possible to use it that way and therefore would consider continuing to use in the same way but through migration to the functions available in the database's class.
Zen Follower
Zen Follower
Totally Zenned
wolfderby:
So basically I got it sort of working, :/ . But it's probably not use-able. I did these rounding error mods (https://www.zen-cart.com/showthread.php?209786-Shopping-cart-Subtotal-not-equal-Checkout-Subtotal-(rounding-error)-with-GST-VAT/page2) a while back, that I think back-fired w/ the QB import, because it kept throwing an error on import into QB 2016 (The transaction is not in balance. Make sure the amounts in the detail area on the form for this transaction equal the amount at the top of the form.) Then I'd also end up w/ an "error on line XX: can't record invalid transaction error"
I compared the iif w/ qb's latest example but I probably need to dig back further for something to match better.
Long story short I jammed most of my 2017 transactions into a backed up QB company file only to have most of the data look good until I attempted to open the account register within QB and it would just error and crash QB.
If anyone's interested in what I have or thinks I should upload it as it's probably "better" than what I last uploaded let me know. I think I'm bailing on this in the meantime.
New Zenner
Totally Zenned
New Zenner
wolfderby:
so I'm trying to update this add-on but I need a little help getting the admin page registration working but possibly more importantly this error sorted out to make sure it'll all be worth it:
[07-Jan-2018 01:27:35 America/New_York] Request URI: /spelL-MUd-shoRe/qbi_config.php, IP address: 73.52.227.139
#1 mysqli_real_escape_string() called at [/home/content/62/5902262/html/MY_ADMIN/includes/functions/qbi_functions.php:152]
#2 mysql_escape_string_array()
#3 array_walk() called at [/home/content/62/5902262/html/MY_ADMIN/includes/classes/qbi_classes.php:2610]
#4 Proc_form->proc_cleanData() called at [/home/content/62/5902262/html/MY_ADMIN/qbi_config.php:30]
[08-Jan-2018 15:36:37 America/New_York] PHP Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, string given in /home/content/62/5902262/html/MY_ADMIN/includes/functions/qbi_functions.php on line 154
here's the guilty function:
function mysql_escape_string_array(&$var, $db) { if (is_array($var)) { array_walk($var,'mysql_escape_string_array', $db); } else { $var=mysqli_real_escape_string($db,$var); // This function is deprecated. PHP>=4.3.0 may use mysql_real_escape_string } return $var; }
if I switch it to mysql_real_escape_string( and swap the order of the parameters as needed) it php errors about $db not being a resource.
I don't quite understand constructors or classes at this point in my programming experience but this qbi_mysql.php file contains this:
function & query($sql) { $this->dbConn = mysqli_connect($this->host, $this->dbUser, $this->dbPass, $this->dbName); if (!$queryResource=mysqli_query($this->dbConn,$sql)) { trigger_error ('Query failed: '.mysqli_error($this->dbConn).' SQL: '.$sql); } return new MySQLResult($this,$queryResource); } }
which might help someone suggest a solution possibly?
New Zenner
Administrator
New Zenner
New Zenner
SblantonMMP:
Hello,
We've got the latest version installed onto a version 1.5.6c Zencart installation. I've followed the instructions on getting it configured and I've setup and matched the products/payments/etc. I've been able to create an iif file and download orders to QuickBooks. When I import the file it will create the sales receipt like I want. It includes the payment method (Credit Card) and shipping method (US Mail) on the receipt with all the other information.
Based on what I've read it should also import payments. It does put the correct amounts into the correct accounts, but it does not mark the sales receipts as paid. When I go to customer accounts, it does not show open balances for these receipts and customers. Is there something else I need to configure to have the sales receipts marked as "Paid" so that the "Paid" stamp will print when the invoice is printed? Am I expecting something that this won't do?
Thanks for any help and suggestions!
Destination thread ID and reason are required when shown.
Tell staff why this post should be reviewed.
Required for login, security, and core site functionality.
Help us understand how the site is used so we can improve it.
Used for promotion and personalized campaign measurement.