title: Selecting data from MySQL DB using the ID in URL
body: <p>I'm trying to pull data in a database from the ID in the URL.</p>
  
  <p>Basically someone clicks on a category link. Then the category name goes into the URL. So the URL looks like this when clicking on the "action" category: <code>http://localhost:8888/test/category.php?id=action</code></p>
  
  <p>I want to then grab everything in the database that equals to the category in the URL - so grab all "action" items in the database which is in a column called "category"</p>
  
  <p>Here is the PHP code I'm working on below. I get this error:
  <code>There was an error running the query [Unknown column 'action' in 'where clause']</code></p>
  
  <p>PHP code:</p>
  
  <pre><code>&lt;?php
  $db = new mysqli('localhost', 'root', 'root', 'test');
  
  if($db-&gt;connect_errno &gt; 0){
      die('Unable to connect to database [' . $db-&gt;connect_error . ']');
  }
  
  $id = mysql_real_escape_string($_GET['id']);
  $sql = &lt;&lt;&lt;SQL
      SELECT *
      FROM `games_db`
      WHERE `category` = ($id)
  SQL;
  
  if(!$result = $db-&gt;query($sql)){
      die('There was an error running the query [' . $db-&gt;error . ']');
  }
  while($row = $result-&gt;fetch_assoc()){
      echo '&lt;h2&gt;' . $row['title'] . '&lt;/h2&gt;' . ' ' . $row['description'] . '&lt;br /&gt;&lt;br /&gt;';
  }
  
  
  echo 'Total results: ' . $result-&gt;num_rows;
  
  // Free result set
  mysqli_free_result($result);
  
  mysqli_close($db);
  ?&gt;
  </code></pre>