title: Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\glasanje\index.php on line 111
body: <pre><code>&lt;?php
  
      foreach (iscupaj_viceve() as $id =&gt; $glasanje){
  
          $result = mysql_query("SELECT * FROM vicevi WHERE id = $id");
          while ($row = mysql_fetch_array($query)) {
              echo    "&lt;h2&gt;&lt;center&gt;".$row['Title']."&lt;/h2&gt;";
              echo    "&lt;div id='linkovi1'&gt;" .nl2br($row["VicText"]). "&lt;br&gt;&lt;/div&gt;";
          }
  ?&gt;
      &lt;p&gt;
  
              &lt;a href="?glasanje=gore&amp;id=&lt;?php echo $id; ?&gt;"&gt;&lt;img src="../images/plus_sign.png" width="29" height="29"&gt;&lt;/a&gt;
              &lt;a href="?glasanje=dolje&amp;id=&lt;?php echo $id; ?&gt;"&gt;&lt;img src="../images/minus_sign.png" width="29" height="29"&gt;&lt;/a&gt;
          Ukupno glasova : [
          &lt;?php
              include 'core/db/connect.php';
              // Check connection
              $result = mysql_query("SELECT glasanje FROM vicevi WHERE id = $id");
  
              while($row = mysql_fetch_array($result))
              {
              echo nl2br($row['glasanje']);
              }
          ?&gt;]
      &lt;/p&gt;
  &lt;?php
  
      }
  
  ?&gt;
  </code></pre>
  
  <p>And this is my function</p>
  
  <pre><code>function iscupaj_viceve(){
  
  
  $sql = "SELECT id, VicText, glasanje FROM vicevi ORDER BY id DESC LIMIT 0, 10";
  
  $rezultati = mysql_query($sql);
  $glasanje = array();
  
  while (($row = mysql_fetch_assoc($rezultati)) !== false){
      $rezultati[$row['id']] = $row['VicText'];
  }
  return $rezultati;
  </code></pre>
  
  <p>}</p>
  
  <p>Browser prints this error message:</p>
  
  <p>Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\glasanje\index.php on line 111</p>
  
  <p>But i can't seem to find a way to solve this problem :S Help?</p>