title: PHP last_activity
body: <p>I'm coding a little website where users can login. Now I want to show the last activity from each user.</p>
  
  <p>I add a row called <code>last_activity</code> as <code>INT</code> to my database. I found that one: <a href="https://stackoverflow.com/questions/9619451/php-last-log-in-script?answertab=votes#tab-top">PHP Last log in script</a> and tried do it like that.</p>
  
  <pre class="lang-php prettyprint-override"><code>$statement = $pdo-&gt;prepare("UPDATE users SET last_activity = ".time()." WHERE id = ".$id."");
  $result =  $statement-&gt;execute();
  
  $state = $pdo-&gt;prepare("SELECT last_activity FROM users WHERE id = ".$id.", 0");
  $result = $state-&gt;execute();
  $activity = $state-&gt;fetch();
  </code></pre>
  
  <p>and to show</p>
  
  <pre class="lang-php prettyprint-override"><code>echo relativeTime($activity);
  </code></pre>
  
  <blockquote>
    <p>PDOStatement Error: PDOStatement::errorInfo(): Array ( [0] => 00000 [1] => 1064 [2] => 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 ' 0' at line 1 )</p>
  </blockquote>
  
  <p>And it shows whatever I do -> 50 years ago (from function <code>relativeTime</code>)</p>