PHP invalid argument in foreach loop
<p>I have a main php file that I am including in my php file that I am calling the functions from.</p>

<p>My main file has this function</p>

<pre><code>function GetComments()
{
global $server;
global $info;
global $dbhandle;

$query = "SELECT GbId, fname, lname, comment FROM Guestbook";

$result = sqlsrv_query($dbhandle, $query);

while($row = sqlsrv_fetch_array( $result, SQLSRV_FETCH_ASSOC))
{
$array[$row['GbId']] = array(
'f' =&gt; trim($row['fname']),
'l' =&gt; trim($row['lname']),
'c' =&gt; trim($row['comment']));
}

return $array;
}
</code></pre>

<p>and my webpage document has this code</p>

<pre><code>&lt;?php
$array = GetComments();

foreach($array as $key =&gt; $info)
{
echo $info['f']." ".$info['l']." said "."&amp;quot;".$info['c']."&amp;quot;"."&lt;br /&gt;&lt;br /&gt;";
}

Close();
?&gt;
</code></pre>

<p>This code works fine when the foreach loop is in the main file, but I get a warning after all the data is printed out when it is in the webpage file.  I'm not too concerned about it as it still works, but I would like to either get rid of it, fix it, or at least know why it is happening.</p>

<p>Thanks</p>
