title: Undefined variable: records in C:\XAMPP\htdocs\display_prsc.php on line 29
body: <p>I want to retrieve data from MySql table. I am using Xampp, phpMyAdmin etc... I followed this tutorial step by step: <a href="https://www.youtube.com/watch?v=IHdd02IK2Jg" rel="nofollow">https://www.youtube.com/watch?v=IHdd02IK2Jg</a></p>
  
  <p>But I get this error:</p>
  
  <blockquote>
    <p>Notice: Undefined variable: records in C:\XAMPP\htdocs\display_prsc.php on line 29</p>
  </blockquote>
  
  <p>And a warning:</p>
  
  <blockquote>
    <p>Warning: mysql_fetch_assoc() expects parameter 1 to be resource, null given in C:\XAMPP\htdocs\display_prsc.php on line 29</p>
  </blockquote>
  
  <p>It just displays the column names when i run it.</p>
  
  <pre><code>    &lt;? php
  
         //make connection
         mysql_connect('localhost','root','');
  
         //select_db
         mysql_select_db('mynewdb');
  
         $sql="SELECT * FROM new";
  
         $records=mysql_query($sql);
      ?&gt;
  
      &lt;html&gt;
      &lt;head&gt;
      &lt;title&gt;Program Scores Table&lt;/title&gt;
  
      &lt;body&gt;
  
       &lt;table width="600" border="1" cellpadding="1" cellspacing="1"&gt;
       &lt;tr&gt;
               &lt;th&gt;Year&lt;/th&gt;
               &lt;th&gt;Criteria&lt;/th&gt;
               &lt;th&gt;Score&lt;/th&gt;
       &lt;tr&gt;
  
      &lt;?php
  
         while ($new=mysql_fetch_assoc($records)){
  
               echo"&lt;tr&gt;";
               echo"&lt;td&gt;".$new['py']."&lt;/td&gt;";
               echo"&lt;td&gt;".$new['pcrit']."&lt;/td&gt;";
               echo"&lt;td&gt;".$new['psco']."&lt;/td&gt;";
               echo"&lt;/tr&gt;";
         }
       ?&gt;
  
        &lt;/table&gt;
        &lt;/body&gt;
        &lt;/head&gt;
        &lt;/html&gt;
  </code></pre>