oracle765 Posted February 23, 2015 Share Posted February 23, 2015 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 Quote Link to comment https://forums.phpfreaks.com/topic/294844-illegal-string-offset-php-error/ Share on other sites More sharing options...
tryingtolearn Posted February 24, 2015 Share Posted February 24, 2015 Looks like $img isnt an array but that is what you are calling Use var_dump() to check what comes back. var_dump($img); Quote Link to comment https://forums.phpfreaks.com/topic/294844-illegal-string-offset-php-error/#findComment-1506553 Share on other sites More sharing options...
blacknight Posted February 24, 2015 Share Posted February 24, 2015 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 Quote Link to comment https://forums.phpfreaks.com/topic/294844-illegal-string-offset-php-error/#findComment-1506565 Share on other sites More sharing options...
oracle765 Posted March 1, 2015 Author Share Posted March 1, 2015 hi blacknight thanks for that It has that line twice in the code provided so would I change it in both places thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/294844-illegal-string-offset-php-error/#findComment-1507182 Share on other sites More sharing options...
mac_gyver Posted March 2, 2015 Share Posted March 2, 2015 the information that blacknight posted has nothing to do with the problem. i suggest you read what tryingtolearn posted. Quote Link to comment https://forums.phpfreaks.com/topic/294844-illegal-string-offset-php-error/#findComment-1507233 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.