Note that there are some explanatory texts on larger screens.

plurals
  1. POCode works in PHP 5.3.2. In PHP 5.2.17 get Invalid argument supplied for foreach()
    primarykey
    data
    text
    <p>I am using this code:-</p> <pre><code>&lt;?php // Load and parse the XML document $rss = simplexml_load_file('http://partners.userland.com/nytRss/nytHomepage.xml'); $title = $rss-&gt;channel-&gt;title; ?&gt; &lt;html xml:lang="en" lang="en"&gt; &lt;head&gt; &lt;title&gt;&lt;?php echo $title; ?&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;&lt;?php echo $title; ?&gt;&lt;/h1&gt; &lt;?php // Here we'll put a loop to include each item's title and description foreach ($rss-&gt;channel-&gt;item as $item) { echo "&lt;h2&gt;&lt;a href='" . $item-&gt;link . "'&gt;" . $item-&gt;title . "&lt;/a&gt;&lt;/h2&gt;"; echo "&lt;p&gt;" . $item-&gt;description . "&lt;/p&gt;"; } ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Which I got from this site www.ibm.com/developerworks/library/x-simplexml.html</p> <p>I have one puzzling issue.</p> <p>When I run the code on my development server it works with no problem.</p> <p>When I run it on my web host server I get this error report:-</p> <blockquote> <p>Warning: Invalid argument supplied for foreach() in /web1/............../test3.php on line 15</p> </blockquote> <p>My development server is a TurnKey Linux LAMP server with PHP 5.3.2.</p> <p>My web host has PHP 5.2.17 running on Linux.</p> <p>Looking up the error message on the web seems to indicate that the data read from the XML feed is not being treated as an array by PHP 5.2.17.</p> <p>The solutions on here under 'Invalid argument....foreach()' that I have tried do not resolve the issue.</p> <p>Any ideas as to how to get around this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload