Forums / General Questions / Illegal string offset 'id' in moneyorder.php

Illegal string offset 'id' in moneyorder.php

Views: 551

Results 1 to 2 of 2
3 Aug 2017, 12:31 AM
#1
d0ugparker avatar

d0ugparker

Zen Follower

Join Date:
May 2008
Location:
Near the water, somewhere...
Posts:
129
Plugin Contributions:
0

Illegal string offset 'id' in moneyorder.php

I'm on 1.5.1 running PHP 5.6 on a shared, GoDaddy cPanel and Linux server.

An error in my log file reads:

"[02-Aug-2017 22:53:24 UTC] PHP Warning: Illegal string offset 'id' in [path-to] moneyorder.php on line 40"

Line 40 in ***moneyorder.php ***is this:

$check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_MONEYORDER_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");

There are two similar forum posts I found for this, calling out 'id' errors concerning orders.php. I was hoping to mimic their fixes.

Their URLs are here:

222150-Illegal-string-offset-id-in-order-php-on-line-462
217764-Illegal-string-offset-id-in-order-php

but their coding at the point of error is very different from what my line 40 in ***moneyorder.php ***line looks like, and I still have my Zencart training wheels on. They're changing the condition of their logical test as quoted below

changing this:

if (STORE_PRODUCT_TAX_BASIS == 'Shipping' && stristr($_SESSION['shipping']['id'], 'storepickup') == TRUE)

to this:

if (STORE_PRODUCT_TAX_BASIS == 'Shipping' && isset($_SESSION['shipping']['id']) && stristr($_SESSION['shipping']['id'], 'storepickup') == TRUE)

I attempted to construct the SQL it's constructing, but got lost at trying to figure out what

MODULE_PAYMENT_MONEYORDER_ZONE

was. I was hoping the

['country']['id']

toward the end of the query would have revealed something to the SQL parser that might have given me a clue on how to massage the code into what's right, but my SQL training wheels are bigger than my Zencart, PHP training wheels.

Incidental comment, the PHP tags in the post editor look really great when I'm reading the text version of a post I'm constructing, but when I preview the PHP code, the window that displays the PHP code is the tiniest, thinnest, single line, horizontal window that even cuts off the bottom half of the single line it's attempting to display and, IMHO needs to be at least four times taller. The reason I used QUOTE tags is so I could see all the code, because the PHP tags made the window tiny and forced me to scroll in a 0.5 x 80 character sliver of a window. The default PHP window display size needs attention.

Let me rephrase that: it needs A LOT of attention.

3 Aug 2017, 4:07 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Illegal string offset 'id' in moneyorder.php

d0ugparker:

I'm on 1.5.1 running PHP 5.6
Zen Cart v1.5.1 was published before PHP 5.6 was even conceived.

d0ugparker:

Let me rephrase that: it needs A LOT of attention.
You're right, if you're referring to your long-overdue-for-an-upgrade site.

You need to upgrade to a modern version of Zen Cart if you want to use a modern version of PHP.

The ['id'] warnings were (mostly) fixed in v1.5.4 and (fully) in v1.5.5

Your Zen Cart version is from 2012 ... and numerous updates have been published since then. Time to upgrade. Then those errors/warnings will go away.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.