title: How to check whether $_GET['id'] is set and it's not empty using php
body: <p>Here's a php code</p>
  
  <pre><code>if(isset($_GET['id'])) {
      //do something
  } else {
      redirect('index.php'); //redirect is a function
  }
  </code></pre>
  
  <p>Now if id is set (ex: index.php?id=12) then the action is performed but if id is not set (ex: index.php?id=) this shows an error, how to overcome this...??</p>
  
  <p>How to determine id is an integer and it's not empty and then perform the specific action....</p>
  
  <p>Edited</p>
  
  <p>Thank you all for your answers but i am still getting that error...</p>
  
  <pre><code>if(isset($_GET['id'])) { // I implemented all these codes but still....
      $user= User::find_by_id($_GET['id']);
     // Database Classes Fetches user info from database
  }
  else {
      redirect('index.php'); //redirect function
  }
  </code></pre>
  
  <p>If the id is 1 or greater than 1 then the script executes perfectly. ( index.php?id=1 )</p>
  
  <p>But id i set id as noting i get an error i..e index.php?id=</p>
  
  <p>The code should automatically redirect user to the index.php page instead of showing an error.....</p>
  
  <p>ERROR : Database query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 1' at line 1</p>