title: Invalid query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax
body: <p>When this script is being runned:</p>
  
  <pre><code>&lt;?php
        $username = "root";
        $host = "localhost";
        $pass = "mypass";
        $db = "api";
        $key = $_GET['key'];
        mysql_connect("$host", "$username", "$pass")or die("cannot connect"); 
        mysql_select_db("$db")or die("cannot select DB");
        $key = stripslashes($key);
        $key = mysql_real_escape_string($key);
        $result = mysql_query("SELECT * FROM keys WHERE key='. $key .'");
        if (!$result) { // add this check.
           die('Invalid query: ' . mysql_error());
        }else{
           echo "done";
        }
  ?&gt;
  </code></pre>
  
  <p>It shows me the error:</p>
  
  <blockquote>
    <p>Invalid query: 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 'keys WHERE key='. aL6MP .'' at line 1</p>
  </blockquote>