title: Selecting multiple rows in PHP using MySQL
body: <p>Why cant I make this code block work? Even though the connection was successful it still returns Error in your query?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>function selectMultiRows($query) 
  {    
      if((@$result = mysql_query ($query))==FALSE) 
         { 
          echo "&lt;strong&gt;Error in your query:&lt;/strong&gt; &lt;br&gt;$query"; 
      }    
      else 
      {     
          $count = 0; 
          $data = array(); 
          while ( $row = mysql_fetch_array($result)) 
          { 
              $data[$count] = $row; 
              $count++; 
          } 
              return $data; 
      } 
  } 
  
   
  $query = "select * from Users"; 
  $returnedData = selectMultiRows($query); 
  $totalRecords =  count($returnedData); 
  
  for($i=0;$i&lt;$totalRecords;$i++) 
  { 
      echo $returnedData[$i]["username"] . "&lt;br&gt;"; 
  }</code></pre>
  </div>
  </div>
  </p>