Jump to content

illegal string offset php error


oracle765

Recommended Posts

PHP Warning:  Illegal string offset 'url' in /hotel_details.php on line 164
PHP Warning:  Illegal string offset 'thumbnailUrl' in /hotel_details.php on line 164
PHP Warning:  Illegal string offset 'thumbnailUrl' in /hotel_details.php on line 166
PHP Warning:  Illegal string offset 'url' in /hotel_details.php on line 167
PHP Warning:  Illegal string offset 'url' in /hotel_details.php on line 177



Here is the code in question from lines 153 to 180

<!-- Elastislide Carousel -->
               <ul id="carousel" class="elastislide-list">
               <!--<ul >-->
                <?php
                if($respon['HotelInformationResponse']['HotelImages']['HotelImage'] !="")
                {
                $i= 0;
                foreach($respon['HotelInformationResponse']['HotelImages']['HotelImage'] as $img)
                {
                    $i++;
                ?>
                    <li data-preview="<?php echo $img['url']; ?>" id="pr_<?php echo $i;?>"><a href="javascript:void(0);" ><img src="<?php echo $img['thumbnailUrl']; ?>" alt="image-preview" id="anc_<?php echo $i;?>" onMouseOver="div.show('div<?php echo $i ;?>')" onMouseOut="div.hide('div<?php echo $i ;?>')"/></a></li>
                    
                     <!--<li><img src="<?php echo $img['thumbnailUrl']; ?>" alt="" height="70" width="70"  onMouseOver="div.show('div<?php echo $i ;?>')" onMouseOut="div.hide('div<?php echo $i ;?>')"/>
                    <img src="<?php echo $img['url']; ?>" class="zoom-image" id="div<?php echo $i ;?>" alt="" style="visibility: hidden"/></li>-->
                <?php } ?>
               <!--</ul>-->
              </ul>
               <?php
                $i= 0;
                foreach($respon['HotelInformationResponse']['HotelImages']['HotelImage'] as $img)
                {
                    $i++;
               ?>                    
                    <img src="<?php echo $img['url']; ?>" class="zoom-image" id="div<?php echo $i ;?>" alt="" style="visibility: hidden"/>
                <?php } }
                ?>
                <!-- End Elastislide Carousel -->

Hi All

 

I am receiving this error and I have no idea what to do, any ideas what could be wrong

 

 

thanks in advance

 

 

Link to comment
https://forums.phpfreaks.com/topic/294844-illegal-string-offset-php-error/
Share on other sites

one could change

 foreach($respon['HotelInformationResponse']['HotelImages']['HotelImage'] as $img)

to 

 foreach($respon['HotelInformationResponse']['HotelImages']['HotelImage'] as $index => $img)

and it "should" work. as long as there is data in the $img array

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.