• Hello,

    Since I did update my wordpress, i get the followign error:
    Invalid argument supplied for foreach()..etc.. on line 41.

    The code on line 41 is:

    foreach($restaurants as $restaurant){
        if ($restaurant['restaurant_poperty_photo'][1]['t']==""){
        $foto='https://www.gershon-lehrer.be/blog/wp-content/uploads/noPhotoAvailable.png';
        } else
        {$foto=$restaurant['restaurant_poperty_name'][1];};
        echo "<b>Photo:</b><img src='".$foto."'><br />";
        echo "<b>Name:</b>".$restaurant['restaurant_poperty_name'][1]."<br />";
        echo "<b>Address:</b>".$restaurant['restaurant_poperty_address'][1]."<br />";
        echo "<b>City:</b>".$restaurant['restaurant_city'][1]."<br />";
        echo "<b>Country:</b>".$restaurant['restaurant_country'][1]."<br />";
        echo "<b>Phone Number:</b>".$restaurant['restaurant_poperty_phone'][1]."<br />";
        echo "<b>Website:</b><a href='".$restaurant['restaurant_poperty_url'][1]."' target=\'_blank\'>".$restaurant['restaurant_poperty_url'][1]."</a><br />";
        echo "<b>e-mail address:</b><a href='mailto:".$restaurant['restaurant_poperty_e_mail'][1]."'>".$restaurant['restaurant_poperty_e_mail'][1]."</a><br />";
        echo "<b>Rate:</b>".$restaurant['restaurant_poperty_rate'][1]."<br />";
        echo "<b>Comments:</b>".$restaurant['restaurant_poperty_comments'][1]."<br />";
        echo "<b>Map:<b><br>".GeoMashup::map('height=400&width=700&zoom=13');
      }

    Any tips?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author hunk

    (@hunk)

    add a if conditional

    if($restaurants){
    foreach($restaurants as $restaurant){
    //code
    }
    }

    Thread Starter glehrer

    (@glehrer)

    Thanks!

    I had the same problem and tried to throw the if statement in there, but now it’s just not outputting anything at all. Here’s my code:

    <?php
    	$column_2 = getGroupOrder('column_2');
    	if($column_2) {
    	foreach($column_2 as $column_two){
    		echo get('column_2_news_headline', $column_two)."<br />";
    		echo get('column_2_news_paragraph', $column_two)."<br /><br />";
    }}
    ?>

    Any idea?

    I also tried this:

    <?php
    	$test = getGroupOrder('test');
    	if($test) {
    	foreach($test as $tests){
    		echo $tests['test_first'][1]."<br />";
    		echo $tests['test_second'][1]."<br />";
    }}

    I’ve figured it out, I had the first line wrong…Here wes my final code in case anyone is interested in the future:

    <?php
    	$test = get_group('test');
    	if($test) {
    	foreach($test as $tests){
    		echo $tests['test_first'][1]."<br />";
    		echo $tests['test_second'][1]."<br />";
    	}}
    ?>

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Invalid argument supplied for foreach()’ is closed to new replies.