title: Simple PHP Voting System
body: <p>I have a simple application which allows users to submit 'problems' and then comment on them. I am attempting to make a simple voting system so users can 'vote up' problems which in turn will push them higher up a list. I have some basic knowledge of PHP and everything so far is working, I just can't figure out how to get this to work.</p>
  
  <p>I've followed a tutorial online and so far have this on my problem.php page...</p>
  
  <pre><code>if (isset($_GET['vote'], $_GET['id'])){
          add_problem_vote($_GET['id]'], $_GET['vote']);
      }
  
  &lt;a href="?vote=up&amp;amp;id=&lt;?php echo $problemID; ?&gt;"&gt;Vote&lt;/a&gt;
  </code></pre>
  
  <p>And on my functions.php page...</p>
  
  <pre><code>function add_problem_vote($problemID, $vote){
  
      $problemID = (int)$problemID;
  
      $vote = ($vote === 'up') ? '+' : '-';
  
      $sql = "UPDATE `problems` SET `votes` = `votes` {$vote} 1 WHERE `id` = {$problem_id}";
  
      mysql_query($sql);
  }
  </code></pre>
  
  <p>All my table fields are definitely named correctly. I know there are many things to consider like re-voting after the session has closed but as long as I have shown the idea it doesn't have to be perfect. At the minute when the link is clicked it redirects to a page but the votes don't change in the mysql table. </p>