Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2018
    Posts
    165
    Plugin Contributions
    4

    Default Cannot use string offset as an array?

    I am not sure what mod this is from but it has to do with additional images; I think it's from Zen lightbox.

    When I add additional images in the admin and go to my store I get this error in my log. I am guessing because of php7.

    PHP Fatal error: Uncaught Error: Cannot use string offset as an array

    PHP Code:
    $image_regular zen_image($products_image_medium$products_ar['products_name'], $width$height'class="adt-img"');
            
    $large_link zen_href_link(FILENAME_POPUP_IMAGE_ADDITIONAL'pID=' $products_id '&pic=' $i '&products_image_large_additional=' $products_image_medium'SSL');
            
    $script_link '<a href="'.$product_link.'" title="' $products_ar['products_name'] . '">' $image_regular .'</a>';
            
    // List Box array generation:
            
    $list_box_contents[$row][$col] = array('params' => 'class="item "''text' => array("imglink"=>$script_link"img"=>$image_regular));
            
    $col ++;
            if (
    $col > (IMAGES_AUTO_ADDED -1)) {
              
    $col 0;
              
    $row ++;
            } 

  2. #2
    Join Date
    Jan 2018
    Posts
    165
    Plugin Contributions
    4

    Default Re: Cannot use string offset as an array?

    I think its from Image Handler nevermind

  3. #3
    Join Date
    Jan 2018
    Posts
    165
    Plugin Contributions
    4

    Default Re: Cannot use string offset as an array?

    I am guessing need to add $list_box_contents = array();

  4. #4
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Cannot use string offset as an array?

    Quote Originally Posted by tmccaff View Post
    I am not sure what mod this is from but it has to do with additional images; I think it's from Zen lightbox.

    When I add additional images in the admin and go to my store I get this error in my log. I am guessing because of php7.

    PHP Fatal error: Uncaught Error: Cannot use string offset as an array

    PHP Code:
    $image_regular zen_image($products_image_medium$products_ar['products_name'], $width$height'class="adt-img"');
            
    $large_link zen_href_link(FILENAME_POPUP_IMAGE_ADDITIONAL'pID=' $products_id '&pic=' $i '&products_image_large_additional=' $products_image_medium'SSL');
            
    $script_link '<a href="'.$product_link.'" title="' $products_ar['products_name'] . '">' $image_regular .'</a>';
            
    // List Box array generation:
            
    $list_box_contents[$row][$col] = array('params' => 'class="item "''text' => array("imglink"=>$script_link"img"=>$image_regular));
            
    $col ++;
            if (
    $col > (IMAGES_AUTO_ADDED -1)) {
              
    $col 0;
              
    $row ++;
            } 
    Hold up there buck-a-roo.
    Once (twice? Or third time?) again, there is insufficient information provided to begin to help...
    Here is why I say that:
    There is a problem with an array assignment (jist of the error message), almost 50% of the provided lines of code have an array in them.
    If there was some sort of formatting applied internal to the snippet of code to try to point out which line was the problem, well the [PHP][/PHP] tags were used instead of [CODE][/CODE] tags the tags used offer syntax formatting which yes can help identify say unbalanced quotes and other general syntax errors (forgot a $ at the start of a variable, etc...)
    The description of the process of the log generation doesn't identify at what point in the process the log is generated (ie. If it is an admin mydebug log or a catalog mydebug log)
    There is no identification in this post about what ZC version is involved and other than possibly blaiming another plugin it is not identified what else is installed but then shortly after this a similar message (double posting) has been posted to Image Handler 4.
    As to "fault", php7 and above is where the php community is going. The majority of issues "raised" in php7 are for the most part preventable at early php 5 if not php 4 days, but... it is only/mostly now in php 7 that the expectations of programmers and code are stricter. This is a good thing.

    So, okay all that above, but that's just what's made available here, those that have read other posts or followed along or had similar comments would expect to be able to say that we're talking about ZC 1.5.5 I thought sub-version f was applie, I could be wrong. At any rate, as another note where one needs to read as part of installation, IH4 was basically abandoned at the point of ZC 1.5.5 and a new version generated that has its own support thread. Meaning, if you are using ZC 1.5.5 then you should be using IH5 not IH4 which would likely be part of the problem from above.

    Beyond that, more than likely one of those "array" variables was previously declared as a string which was the "old" way to declare such empty values. Afterall, a string is/was an array of characters right?
    So you would look for a condition like $array_name = ''; somewhere above what has been provided because there is no initial code assignment in the above snippet.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Jan 2018
    Posts
    165
    Plugin Contributions
    4

    Default Re: Cannot use string offset as an array?

    I searched for Image handler and only found Image handler 4 not 5. Do you know where it's located?

  6. #6
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Cannot use string offset as an array?

    Quote Originally Posted by tmccaff View Post
    I searched for Image handler and only found Image handler 4 not 5. Do you know where it's located?
    Why, unlike image handler 2, 3, and 4 it doesn't show up on a simple search for image handler (other than the added -5) I'm not sure, but the download area is: https://www.zen-cart.com/downloads.php?do=file&id=2169
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #7
    Join Date
    Jan 2018
    Posts
    165
    Plugin Contributions
    4

    Default Re: Cannot use string offset as an array?

    I found the support thread; thanks so much for that

    https://www.zen-cart.com/showthread....t-Thread/page5

 

 

Similar Threads

  1. UPSXML error: Cannot use string offset as an array
    By callingrohit in forum Addon Shipping Modules
    Replies: 9
    Last Post: 16 Sep 2008, 06:23 PM
  2. Cannot use string offset as an array - error in UPSXML module
    By tat2nu in forum Addon Shipping Modules
    Replies: 5
    Last Post: 14 Aug 2008, 08:35 PM
  3. Replies: 4
    Last Post: 21 Mar 2008, 06:41 PM
  4. Fatal error: Cannot use string offset as an array in upsxml.php
    By yaby in forum Addon Shipping Modules
    Replies: 4
    Last Post: 19 Oct 2007, 06:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR