Forums / Addon Shipping Modules / Stamps.com getting error while importing

Stamps.com getting error while importing

Results 1 to 20 of 38
15 Sep 2010, 12:41
#1
helpme avatar

helpme

Totally Zenned

Join Date:
Apr 2007
Posts:
632
Plugin Contributions:
0

Stamps.com getting error while importing

I am trying to use Stamps.com, but where the heck is the batch file??? I can't find it anywhere.
15 Sep 2010, 17:19
#2
stampscom avatar

stampscom

New Zenner

Join Date:
Dec 2009
Posts:
54
Plugin Contributions:
0

Re: Stamps.com getting error while importing

Hello,

If there is anything else you need help with, please feel free to let me know.

Thanks!
Chuck
Stamps.com
30 Aug 2014, 01:47
#3
vanhorn_s avatar

vanhorn_s

Zen Follower

Join Date:
Apr 2010
Posts:
283
Plugin Contributions:
0

Re: Stamps.com getting error while importing

I just got done upgrading to 1.5.3, and stamps.com will no longer import orders. It appears to be a compatibility issue, but I have no clue what to edit, so that it will work again. I tested, and it can access the database by doing this:

https:// my site admin /stamps.php?shipping_access_token=XXXXXXXXXXXXXXXXXXXXXX&cmd=ping

I have already tried the latest stamps.com integration software, and they claim it has only been tested to work up to 1.5.0
30 Aug 2014, 13:39
#4
rixstix avatar

rixstix

Totally Zenned

Join Date:
Aug 2009
Posts:
2,015
Plugin Contributions:
0

Re: Stamps.com getting error while importing

Can't help with the Stamps.com issue other than to offer a suggestion.

ShipStation.com has a better interface, has the capability of applying rules and filters that you build to orders imported and has the ability to use both Stamps.com (or Endicia) and Express1 rates for printing USPS postage. Will also print UPS and Fedex labels if you have accounts with them. When shipping Priority and Express mail, Express 1 rates are better than Stamps.com

OH, and Stamps.com recently bought ShipStation.

If you are not subscribed to receive zencart notices, the zencart USPS plugin will be updated next week so that it will work with the USPS updates that go into effect on Sept 7, 2014.
30 Aug 2014, 16:11
#5
vanhorn_s avatar

vanhorn_s

Zen Follower

Join Date:
Apr 2010
Posts:
283
Plugin Contributions:
0

Re: Stamps.com getting error while importing

I may have to do that. I just don't like how ship station is double the price of stamps.com
30 Aug 2014, 16:38
#6
rixstix avatar

rixstix

Totally Zenned

Join Date:
Aug 2009
Posts:
2,015
Plugin Contributions:
0

Re: Stamps.com getting error while importing

That was my thought too, initially. It doesn't take much shipping per month to offset the expense with timesavings and reduced frustration by not beating my head against the wall every time I had a Stamps.com problem and the months it took for them to address the problems.
30 Aug 2014, 19:18
#7
vanhorn_s avatar

vanhorn_s

Zen Follower

Join Date:
Apr 2010
Posts:
283
Plugin Contributions:
0

Re: Stamps.com getting error while importing

I started the free trial of ship station, and I really like how it works, but it is going to cost me $65 a month, because I also import orders from Ebay, and Paypal.
30 Aug 2014, 19:43
#8
rixstix avatar

rixstix

Totally Zenned

Join Date:
Aug 2009
Posts:
2,015
Plugin Contributions:
0

Re: Stamps.com getting error while importing

Instead of upgrading from bronze to gold,

Try Changing your subscription plan and instead of clicking the upgrade button for silver or gold, look in the upper right of that window and try Increasing the number of selling channels by 2 which appears to keep the features of bronze but allowing 3 channels @ $10/channel instead of $20/channel.
31 Aug 2014, 18:25
#9
vanhorn_s avatar

vanhorn_s

Zen Follower

Join Date:
Apr 2010
Posts:
283
Plugin Contributions:
0

Re: Stamps.com getting error while importing

RixStix:

Instead of upgrading from bronze to gold,

Try Changing your subscription plan and instead of clicking the upgrade button for silver or gold, look in the upper right of that window and try Increasing the number of selling channels by 2 which appears to keep the features of bronze but allowing 3 channels @ $10/channel instead of $20/channel.


Apparently they won't let me do that until the trial is over.


Does anybody have any suggestion on how to add logon credentials to ShippingZSettings.php, or another workaround to make this work again? I can always just use the sales record form Paypal to ship from, but it doesn't post back to zencart.
18 Sep 2015, 16:47
#10
vanhorn_s avatar

vanhorn_s

Zen Follower

Join Date:
Apr 2010
Posts:
283
Plugin Contributions:
0

Re: Stamps.com getting error while importing

I recently upgraded to the new stamps.com software, and you now install it in the admin folder, and it goes straight to the database. It is working flawlessly, except it sets an error in the log folder every time.

I had to edit out the admin folder name, and login credentials on this:
[18-Sep-2015 10:07:27 America/Denver] Request URI: /XXXXXXXXXXXXXXXX/stamps.php?username=XXXXXXXXXXXXXXXX&password=XXXXXXXXXXXXXXXX&action=getorders&maxcount=50&start=2015-09-17T22%3A00%3A51, IP address: 216.52.211.20
#1  mysql_real_escape_string() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:828]
#2  GetCountryID() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:846]
#3  GetStateCode() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:492]
#4  WriteOrder() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:384]
#5  Action_GetOrders() called at [/home2/redsauto/XXXXXXXXXXXXXXXX/stamps.php:176]

[18-Sep-2015 10:07:27 America/Denver] PHP Warning:  mysql_real_escape_string(): Access denied for user 'XXXXXXXXXXXXXXXX'@'localhost' (using password: NO) in /home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php on line 828
[18-Sep-2015 10:07:27 America/Denver] Request URI: XXXXXXXXXXXXXXXX/stamps.php?username=XXXXXXXXXXXXXXXX&password=XXXXXXXXXXXXXXXX&action=getorders&maxcount=50&start=2015-09-17T22%3A00%3A51, IP address: 216.52.211.20
#1  mysql_real_escape_string() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:828]
#2  GetCountryID() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:846]
#3  GetStateCode() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:492]
#4  WriteOrder() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:384]
#5  Action_GetOrders() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:176]

[18-Sep-2015 10:07:27 America/Denver] PHP Warning:  mysql_real_escape_string(): A link to the server could not be established in /home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php on line 828
[18-Sep-2015 10:07:27 America/Denver] Request URI: /XXXXXXXXXXXXXXXX/stamps.php?username=XXXXXXXXXXXXXXXX&password=XXXXXXXXXXXXXXXX&action=getorders&maxcount=50&start=2015-09-17T22%3A00%3A51, IP address: 216.52.211.20
#1  mysql_real_escape_string() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:855]
#2  GetStateCode() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:492]
#3  WriteOrder() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:384]
#4  Action_GetOrders() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:176]

[18-Sep-2015 10:07:27 America/Denver] PHP Warning:  mysql_real_escape_string(): Access denied for user 'XXXXXXXXXXXXXXXX'@'localhost' (using password: NO) in /home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php on line 855
[18-Sep-2015 10:07:27 America/Denver] Request URI: /XXXXXXXXXXXXXXXX/stamps.php?username=XXXXXXXXXXXXXXXX&password=XXXXXXXXXXXXXXXX&action=getorders&maxcount=50&start=2015-09-17T22%3A00%3A51, IP address: 216.52.211.20
#1  mysql_real_escape_string() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:855]
#2  GetStateCode() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:492]
#3  WriteOrder() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:384]
#4  Action_GetOrders() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:176]

[18-Sep-2015 10:07:27 America/Denver] PHP Warning:  mysql_real_escape_string(): A link to the server could not be established in /home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php on line 855
[18-Sep-2015 10:07:27 America/Denver] Request URI: /XXXXXXXXXXXXXXXX/stamps.php?username=XXXXXXXXXXXXXXXX&password=XXXXXXXXXXXXXXXX&action=getorders&maxcount=50&start=2015-09-17T22%3A00%3A51, IP address: 216.52.211.20
#1  mysql_real_escape_string() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:856]
#2  GetStateCode() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:492]
#3  WriteOrder() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:384]
#4  Action_GetOrders() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:176]

[18-Sep-2015 10:07:27 America/Denver] PHP Warning:  mysql_real_escape_string(): Access denied for user 'XXXXXXXXXXXXXXXX'@'localhost' (using password: NO) in /home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php on line 856
[18-Sep-2015 10:07:27 America/Denver] Request URI: /XXXXXXXXXXXXXXXX/stamps.php?username=XXXXXXXXXXXXXXXX&password=XXXXXXXXXXXXXXXX&action=getorders&maxcount=50&start=2015-09-17T22%3A00%3A51, IP address: 216.52.211.20
#1  mysql_real_escape_string() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:856]
#2  GetStateCode() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:492]
#3  WriteOrder() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:384]
#4  Action_GetOrders() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:176]

[18-Sep-2015 10:07:27 America/Denver] PHP Warning:  mysql_real_escape_string(): A link to the server could not be established in /home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php on line 856
[18-Sep-2015 10:07:27 America/Denver] Request URI: /XXXXXXXXXXXXXXXX/stamps.php?username=XXXXXXXXXXXXXXXX&password=XXXXXXXXXXXXXXXX&action=getorders&maxcount=50&start=2015-09-17T22%3A00%3A51, IP address: 216.52.211.20
#1  mysql_real_escape_string() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:828]
#2  GetCountryID() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:846]
#3  GetStateCode() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:506]
#4  WriteOrder() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:384]
#5  Action_GetOrders() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:176]

[18-Sep-2015 10:07:27 America/Denver] PHP Warning:  mysql_real_escape_string(): Access denied for user 'XXXXXXXXXXXXXXXX'@'localhost' (using password: NO) in /home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php on line 828
[18-Sep-2015 10:07:27 America/Denver] Request URI: /XXXXXXXXXXXXXXXX/stamps.php?username=XXXXXXXXXXXXXXXX&password=XXXXXXXXXXXXXXXX&action=getorders&maxcount=50&start=2015-09-17T22%3A00%3A51, IP address: 216.52.211.20
#1  mysql_real_escape_string() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:828]
#2  GetCountryID() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:846]
#3  GetStateCode() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:506]
#4  WriteOrder() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:384]
#5  Action_GetOrders() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:176]

[18-Sep-2015 10:07:27 America/Denver] PHP Warning:  mysql_real_escape_string(): A link to the server could not be established in /home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php on line 828
[18-Sep-2015 10:07:27 America/Denver] Request URI: /XXXXXXXXXXXXXXXX/stamps.php?username=XXXXXXXXXXXXXXXX&password=XXXXXXXXXXXXXXXX&action=getorders&maxcount=50&start=2015-09-17T22%3A00%3A51, IP address: 216.52.211.20
#1  mysql_real_escape_string() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:855]
#2  GetStateCode() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:506]
#3  WriteOrder() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:384]
#4  Action_GetOrders() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:176]

[18-Sep-2015 10:07:27 America/Denver] PHP Warning:  mysql_real_escape_string(): Access denied for user 'XXXXXXXXXXXXXXXX'@'localhost' (using password: NO) in /home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php on line 855
[18-Sep-2015 10:07:27 America/Denver] Request URI: /XXXXXXXXXXXXXXXX/stamps.php?username=XXXXXXXXXXXXXXXX&password=XXXXXXXXXXXXXXXX&action=getorders&maxcount=50&start=2015-09-17T22%3A00%3A51, IP address: 216.52.211.20
#1  mysql_real_escape_string() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:855]
#2  GetStateCode() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:506]
#3  WriteOrder() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:384]
#4  Action_GetOrders() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:176]

[18-Sep-2015 10:07:27 America/Denver] PHP Warning:  mysql_real_escape_string(): A link to the server could not be established in /home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php on line 855
[18-Sep-2015 10:07:27 America/Denver] Request URI: /XXXXXXXXXXXXXXXX/stamps.php?username=XXXXXXXXXXXXXXXX&password=XXXXXXXXXXXXXXXX&action=getorders&maxcount=50&start=2015-09-17T22%3A00%3A51, IP address: 216.52.211.20
#1  mysql_real_escape_string() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:856]
#2  GetStateCode() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:506]
#3  WriteOrder() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:384]
#4  Action_GetOrders() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:176]

[18-Sep-2015 10:07:27 America/Denver] PHP Warning:  mysql_real_escape_string(): Access denied for user 'XXXXXXXXXXXXXXXX'@'localhost' (using password: NO) in /home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php on line 856
[18-Sep-2015 10:07:27 America/Denver] Request URI: /XXXXXXXXXXXXXXXX/stamps.php?username=XXXXXXXXXXXXXXXX&password=XXXXXXXXXXXXXXXX&action=getorders&maxcount=50&start=2015-09-17T22%3A00%3A51, IP address: 216.52.211.20
#1  mysql_real_escape_string() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:856]
#2  GetStateCode() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:506]
#3  WriteOrder() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:384]
#4  Action_GetOrders() called at [/home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php:176]

[18-Sep-2015 10:07:27 America/Denver] PHP Warning:  mysql_real_escape_string(): A link to the server could not be established in /home2/redsauto/public_html/XXXXXXXXXXXXXXXX/stamps.php on line 856


Lines 171-179
                               switch (strtolower($action))
                                {
                                        case 'getmodule': Action_GetModule(); break;
                                        case 'getstore': Action_GetStore(); break;
                                        case 'getcount': Action_GetCount(); break;
                                        case 'getorders': Action_GetOrders(); break;
                                        case 'getstatuscodes': Action_GetStatusCodes(); break;
                                        case 'updatestatus': Action_UpdateStatus(); break;
                                        default: outputError(60, "'$action' not supported");


lines 381-387
                        $processedIds .= $row->fields['orders_id'];

                        // output the order xml
                        WriteOrder($row);

                        // Next order
                        $row->MoveNext();


lines 485-497
                writeStartTag("ShippingAddress");
                writeElement("FullName", $row->fields['delivery_name']);
                writeElement("Company", $row->fields['delivery_company']);
                writeElement("Street1", $row->fields['delivery_street_address']);
                writeElement("Street2", $row->fields['delivery_suburb']);
                writeElement("Street3", "");
                writeElement("City", $row->fields['delivery_city']);
                writeElement("State", GetStateCode($row->fields['delivery_country'], $row->fields['delivery_state']));
                writeElement("PostalCode", $row->fields['delivery_postcode']);
                writeElement("Country", $row->fields['delivery_country']);
                writeElement("Phone", $shipPhone);
                writeElement("Email", $shipEmail);
                writeCloseTag("ShippingAddress");


lines 824-867
        function GetCountryID($country_name)
        {
                global $db;
                $qry = sprintf("select countries_id from ". TABLE_COUNTRIES. " where countries_name = '%s'",
                                mysql_real_escape_string($country_name));

                $countryQuery = $db->Execute($qry);
                if ($countryQuery->RecordCount() == 0)
                {
                        return $country_name;
                }
                else
                {
                        return $countryQuery->fields['countries_id'];
                }
        }

        // Returns the state code for a given state and country name
        function GetStateCode($country_name, $state_name)
        {
                global $db;

                $country_id = GetCountryID($country_name);

                if ($country_id == '')
                {
                        return $state_name;
                }

                // now lookup the state code based on countryid and state name
                $qry = sprintf("select zone_code from ". TABLE_ZONES. " where zone_country_id = '%s' and zone_name = '%s'",
                                mysql_real_escape_string($country_id),
                                mysql_real_escape_string($state_name));
                $stateQuery = $db->Execute($qry);
                if ($stateQuery->RecordCount() == 0)
                {
                        return $state_name;
                }
                else
                {
                        return $stateQuery->fields['zone_code'];
                }

        }
18 Sep 2015, 18:28
#11
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Posts:
13,980
Plugin Contributions:
46

Re: Stamps.com getting error while importing

I've reported this issue to stamps.com (and included the suggested correction). There are 3 areas to be changed:
Line 776:
                $comments = /*mysql_escape_string($_REQUEST['comments'])*/ $db->prepare_input ($_REQUEST['comments']);  //-20150917-lat9  *** 1 of 3 ***

Line 828
                                /*mysql_real_escape_string($country_name)*/ $db->prepare_input ($country_name));  //-20150917-lat9  *** 2 of 3 ***

Lines 854-856
                $qry = sprintf("select zone_code from ". TABLE_ZONES. " where zone_country_id = '%s' and zone_name = '%s'",
                                /*mysql_real_escape_string($country_id)*/ $db->prepare_input ($country_id),
                                /*mysql_real_escape_string($state_name)*/ $db->prepare_input ($state_name));  //-20150917-lat9  *** 3 of 3 ***
18 Sep 2015, 18:40
#12
vanhorn_s avatar

vanhorn_s

Zen Follower

Join Date:
Apr 2010
Posts:
283
Plugin Contributions:
0

Re: Stamps.com getting error while importing

Thank you, that fixed it.
18 Sep 2015, 18:52
#13
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Posts:
13,980
Plugin Contributions:
46

Re: Stamps.com getting error while importing

Excellent! According to the customer-care email that I received from stamps.com, they should have those changes incorporated real-soon-now.
18 Sep 2015, 18:59
#14
vanhorn_s avatar

vanhorn_s

Zen Follower

Join Date:
Apr 2010
Posts:
283
Plugin Contributions:
0

Re: Stamps.com getting error while importing

You mean, two years from now, right?
18 Sep 2015, 19:03
#15
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Posts:
13,980
Plugin Contributions:
46

Re: Stamps.com getting error while importing

vanhorn_s:

You mean, two years from now, right?

We'll see; they were quite responsive to the email query that I sent in. Since they've got the fix, "all" they need to do is re-validate and release!
18 Sep 2015, 19:07
#16
vanhorn_s avatar

vanhorn_s

Zen Follower

Join Date:
Apr 2010
Posts:
283
Plugin Contributions:
0

Re: Stamps.com getting error while importing

The last time I emailed them a fix, they told me they would implement it, but they never did.
18 Sep 2015, 19:10
#17
rixstix avatar

rixstix

Totally Zenned

Join Date:
Aug 2009
Posts:
2,015
Plugin Contributions:
0

Re: Stamps.com getting error while importing

And people ask why we switched from the Stamps.com interface to

ShipStation.com interface with is owned by Stamps.com but easier to implement, more functionality and includes a better rate discount for PriorityMail through an ExpressONE account running parallel to Stamps.com account.

I did receive a notice a few months ago that a priority issue/trouble ticket generated 18 months ago was finally patched.
18 Jun 2017, 17:12
#19
tonyreynolds avatar

tonyreynolds

New Zenner

Join Date:
Dec 2012
Posts:
68
Plugin Contributions:
0

Re: Stamps.com getting error while importing

tonyreynolds:

OK, So I got 1 hit when I searched both on the Admin/Catalog, but zero hits when I searched Catalog only. The stamps.php file is in the catalog root directory. I take the search to mean that the function is not available from the catalog root directory.
I will research to insure the stamps.php file is in the correct location.


TR


The stamps.php file was in the wrong place. It should be in the admin folder and updated to the correct path in the stamps.com software.
Thanks everybody for their help. I learned a new Zen tool as well!

TR
26 Sep 2017, 01:46
#20
tflmike avatar

tflmike

New Zenner

Join Date:
Jul 2014
Posts:
17
Plugin Contributions:
0

Re: Stamps.com getting error while importing

I was able to get stamps.com integration to work with 1.5.5e with this version where I made a few edits to the file to account for the Mysql depreciated functions and replaced them with MySqli equivalents. I am quite sure there are more elegant ways to get this fixed but for now I would like some comments from the other programmers if this compromises security doing it this way.

I modified the original function:
// Returns the zen country id for the given named country
        function GetCountryID($country_name)
        {
                global $db;
                $qry = sprintf("select countries_id from ". TABLE_COUNTRIES. " where countries_name = '%s'",
                                mysql_real_escape_string($country_name));

                $countryQuery = $db->Execute($qry);
                if ($countryQuery->RecordCount() == 0)
                {
                        return $country_name;
                }
                else
                {
                        return $countryQuery->fields['countries_id'];
                }
        }


and changed it to look like this since the mysqli_real_escape_string() requires a connection string as the first parameter:

 // Returns the zen country id for the given named country
        function GetCountryID($country_name)
        {
                global $db;
				$mysqli = new mysqli('DB_SERVER' , 'DB_SERVER_USERNAME' , 'DB_SERVER_PASSWORD' , 'DB_DATABASE' );
                $qry = sprintf("select countries_id from ". TABLE_COUNTRIES. " where countries_name = '%s'",
                                mysqli_real_escape_string($mysqli, $country_name));
								

                $countryQuery = $db->Execute($qry);
                if ($countryQuery->RecordCount() == 0)
                {
                        return $country_name;
                }
                else
                {
                        return $countryQuery->fields['countries_id'];
                }
        }


I did the same for three other functions that were using similar code see the attached updated stamps module if you wish to see the all the changes.