title: Check if post exists
body: <p>So i want to check if a post exists in the database but i have some problems with redirection.
  This is my work so far:</p>
  
  <pre><code>echo '&lt;br&gt;';//the $row part tells the DB what post his looking on
  echo '&lt;a href="comments.php?post_id='. $row['id'].'"&gt;View comments&lt;/a&gt;';
  </code></pre>
  
  <p>This is the show comment button that leads to the section where you see the comments for the post.</p>
  
  <hr>
  
  <pre><code>&lt;?php
  require_once ('checkp.php');
  </code></pre>
  
  <p>I have it to require the post checking script once.</p>
  
  <hr>
  
  <pre><code>&lt;?php
  include ('variables.php');
  //connects to DB
  $dbc=mysql_connect($host,$user,$pass);
  
  
  if ($dbc) {
  
  
   } else {
  
   echo ('Failed to connect to MySql; '. mysql_error());
  
   }
  
  
   //selects db from MySQl
   $sqldb=mysql_select_db('a2318052_blog');
  
   $pid=$_GET['post_id'];
  
   $query1="SELECT * FROM posts_b WHERE id='$pid'";
   $sql=mysql_query($query);
  
   if ($sql) {
  
  
   } else {
  
   echo "cant run query";
  
   }
  
  
   if (mysql_num_rows($sql) &gt; 0) {
  
   echo "that post does not exist!";
  
   } else {
  
   header ("location: comments.php?post_id='. $pid.'");
  
   }
  
   ?&gt;
  </code></pre>
  
  <p>And this is the script that checks for a empty result and then redirects back. I believe its something with the redirect here (header ("location: comments.php?post_id='. $pid.'");)</p>