title: Warning: mysql_error() expects parameter 1 to be resource, string given
body: <pre><code>&lt;?php
   session_start();
  
   $username = "root";
   $password = "password";
   $database = "meipolytechnic";
   mysql_connect('localhost', $username,$password);
   @mysql_select_db($database) or die(mysql_error());
  
  
   $username=$_SESSION['MM_Username'];
   $query = "SELECT rollno FROM users where username = '".$username."'";
   $result = mysql_query($query) or die(mysql_error());
   $num = mysql_num_rows($result);
  
    mysql_close();
  
     $rows = array();
  
     while($r = mysql_fetch_row($result))
  
     {
      $rows[] = $r[0];
     }
  
     echo ($rows['rollno']);
  
     ?&gt;
  </code></pre>
  
  <p>i want to retrieve only the logged in users roll no from users table in database</p>
  
  <p>when i run this code</p>
  
  <p>and log in as foo </p>
  
  <p>i get the following stuff</p>
  
  <p>Unknown column 'foo' in 'where clause'</p>