title: Dynamic select list using SQL data
body: <p>I am trying to create a select drop-down list using php. Every time i try, i get an error.
  Here is my code:</p>
  <p>The function:</p>
  <pre><code>function dropDown(){
      $options=&quot;&lt;select&gt;&quot;; 
      $connect = mysql_connect('localhost','id','pass') or die (&quot;couldn't   connect!&quot;).mysql_error; 
  
      mysql_select_db('db') or die('could not connect to database!');
  
      $sql=&quot;SELECT * FROM DESC&quot;; 
      $result=mysql_query($sql); 
  
      while ($row=mysql_fetch_array($result)) { // this is line 60
          $name=$row[&quot;name&quot;]; 
      
          $options.=&quot;&lt;option value=\&quot;$name\&quot;&gt;&quot;.$name.&quot;&lt;/option&gt;&quot;; 
      } 
  
      $options.= &quot;&lt;/SELECT&gt;&quot;;
      return &quot;$options&quot;;
  }
  </code></pre>
  <p>and then i just call it in my code</p>
  <pre><code>&lt;?php  
  include ('includes/functions.php');
  
  // ...
  
  $list = dropDown();
  echo &quot;$list&quot;;
  
  // ...
  
  ?&gt;
  </code></pre>
  <p>The error I get is:</p>
  <pre class="lang-none prettyprint-override"><code>Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/garagenj/public_html/dispatch/includes/functions.php on line 60
  </code></pre>