title: Getting SQLSTATE[HY000]: General error but query is performed anyway
body: <p>I'm making a system to save users' IPs into a table along with the last time they posted something.
  First, I check for an already-existent record of the user's IP with</p>
  
  <pre><code>SELECT lastpost FROM  users WHERE ip = '$IP'
  </code></pre>
  
  <p>I then check whether the result of that query is empty, and if it is it means that the user's IP is not present and it should be recorded, so I proceed by doing this query:</p>
  
  <pre><code>INSERT INTO users (ip, lastpost) VALUES ('$IP', '$ctime')
  </code></pre>
  
  <p>Where <code>$IP</code> is the user's IP fetched using <code>$_SERVER['REMOTE_ADDR']</code> and <code>$ctime</code> is a time string created <code>using date("Y-m-j H:i:s")</code>.
  Even though after performing the latter query the data is present into the table, I keep getting the error</p>
  
  <pre><code>SQLSTATE[HY000]: General error
  </code></pre>
  
  <p>Which is, by itself, not very helpful. I'd like to understand what I'm doing wrong here. Thanks in advance.</p>
  
  <p><strong>P.S.:</strong> I'll use this question to also ask how I could compare, using a query, the time I have calculated with PHP's <code>date()</code> with the time already present in the table (of type "datetime") to see if the one calculated with <code>date()</code> is greater than the one in the database by at least one minute.</p>