title: Resource id #6 error in PHP with MySQL
body: <p>I am this is for a polling system I am making, this code shows the user a list of questions they can pick from:</p>
  
  <pre><code>        &lt;div class="main_questions"&gt;
              &lt;p class="style1 style2"&gt;&lt;strong&gt;Select Your Question&lt;/strong&gt;&lt;/p&gt;
  
  &lt;p class="style1"&gt;
              &lt;form action="vote_list.php" method="post" name="form1" class="style1"&gt;
              &lt;?php
                          $sql = "SELECT DISTINCT (question_tba) FROM question ORDER BY answer_id DESC";
                          $result = mysql_query($sql);
                          while($row = mysql_fetch_array($result)){
                              ?&gt;
                              &lt;p&gt;
                                  &lt;?php echo $row['question_tba']; ?&gt;
                                  &lt;input type="radio" name="questions" value="&lt;?php echo $row['question_tba']; ?&gt;"&gt;
  
                              &lt;/p&gt;
  
                              &lt;?php
                          }      
              ?&gt;
              &lt;input type="submit" name="submit" value="Vote"&gt;
              &lt;/p&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>This code should then post the chosen question to this page which allows them to cast a vote:</p>
  
  <pre><code>&lt;?php
  
  include('core/initialise.inc.php');
  
  $q = $_POST['question_tba'];
  
  if (isset($_GET['vote'], $_GET['id'])){
      add_vote($_GET['id'], $_GET['vote'], $q);
      echo "&lt;META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0; URL=vote_logged.php\"&gt;";
  }
  
  ?&gt;
  
  &lt;/div&gt;
  &lt;div class="main_questions"&gt;
      &lt;p class="style1 style2"&gt;&lt;strong&gt;Place Your Vote!&lt;/strong&gt;&lt;/p&gt;&lt;?php
          foreach (get_answers($q) as $id =&gt; $answer){
              ?&gt;
              &lt;p&gt;
              &lt;?php echo $answer; ?&gt;
              &lt;a href="?vote=up&amp;amp;id=&lt;?php echo $id; ?&gt;"&gt;Vote&lt;/a&gt;
          &lt;/p&gt;
          &lt;?php
          }
  
          ?&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Then when they click on an answer to vote on the functions on this page should increment the chosen answers vote by 1 using these functions:</p>
  
  <pre><code>&lt;?php
  
  function get_answers($q){
      $q = $q;
      $sql = "SELECT answer_id, answer FROM question WHERE question_tba = '$q'";
      $result = mysql_query($sql);
  
      echo "$result";
  
      $answers = array();
      while (($row = mysql_fetch_assoc($result)) or die(mysql_error()))
      {                                                                         
          $answers[$row['answer_id']] = $row['answer'];
      }
  
      return $answers;
  }
  
  function add_vote($answer_id, $vote, $q2){
      $q2 = $q2;
      $answer_id = (int)$answer_id;
      $vote = '+';
  
      $sql = "UPDATE question SET answer_votes = answer_votes $vote 1 WHERE question_tba = $q2 AND answer_id = $answer_id";
  
      mysql_query($sql);
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>However, my problem is that when I click on the question I would like to vote on, instead of displaying the answers that I can choose to vote from, it just displays Resource id #6. Can anyone tell me what is wrong with my code?</p>