title: mysql_fetch_assoc() error
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/169520/warning-when-using-mysql-fetch-assoc-in-php">Warning when using mysql_fetch_assoc in PHP</a>  </p>
  </blockquote>
  
  
  
  <p>i am having a problem with the following codes, i am new in encountering this error
  here is the code</p>
  
  <pre><code>session_start();
  $uname=$_SESSION['login'];
  
  $host="localhost";
  $username="root";
  $password="";
  $db_name="sampledb";
  $tbl_name="tblsched";
  mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
  mysql_select_db("$db_name")or die("cannot select DB");
  
  $sql = "SELECT * FROM tblteacher WHERE teacherName=$uname";
  $result=mysql_query($sql);
  $row = mysql_fetch_assoc($result);
  
  $teacherid  = $row['teacherID'];
  </code></pre>
  
  <p>it gives me a "mysql_fetch_assoc() expects parameter 1 to be resource, boolean" error, how do i deal with this error?? i have used this code already a few times in other files and it worked perfectly except now, i checked the names of the rows and it was correct</p>
  
  <p>i already tried using other commands such as mysql_fetch_array, mysql_result, mysql_fetch_row and it gives the same error</p>