MYSQL PDO update datetime does nothing
<p>Tried for an hour already. Help pls. Basically i want to update lastlogin column(MYSQL datetime) every time a user login. There is no error message and no update is happening. What is going on?</p>

<p>db.php</p>

<pre><code>&lt;?php 



    // These variables define the connection information for your MySQL database 

    $username = "root"; 

    $password = "root"; 

    $host = "localhost"; 

    $dbname = "rofl"; 



    $options = array(PDO::MYSQL_ATTR_INIT_COMMAND =&gt; 'SET NAMES utf8'); 

    try { $db = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8", $username, $password, $options); } 

    catch(PDOException $ex){ die("Failed to connect to the database: " . $ex-&gt;getMessage());} 

    $db-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 

    $db-&gt;setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); 

    header('Content-Type: text/html; charset=utf-8'); 

    session_start();        

?&gt;
</code></pre>

<p>main.php</p>

<pre><code>&lt;?php 
    include("DB/db.php"); 


        if(!empty($_POST)){   
            $query = " 
                SELECT 
                    userID, 
                    password, 
                    salt, 
                    email 
                FROM user 
                WHERE 
                    userID = :username 
            "; 
            $query_params = array( 
                ':username' =&gt; $_POST['useridforlogin'] 
            ); 

            try{ 
                $stmt = $db-&gt;prepare($query); 
                $result = $stmt-&gt;execute($query_params); 
            } 
            catch(PDOException $ex){ die("Failed to run query: " . $ex-&gt;getMessage()); } 
            $login_ok = false; 
            $row = $stmt-&gt;fetch();

            if($row){ 
                $check_password = hash('sha256', $_POST['passwordforlogin'] . $row['salt']); 
                for($round = 0; $round &lt; 65536; $round++){
                    $check_password = hash('sha256', $check_password . $row['salt']);
                } 
                if($check_password === $row['password']){
                    $login_ok = true;
                } 
            } 
            if($login_ok){ 
                unset($row['salt']); 
                unset($row['password']); 
                $_SESSION['user'] = $row;  

             date_default_timezone_set('Asia/xxxxxx');
    $timestamp = date('Y/m/d h:i:s a', time()); 
    $query2 = "UPDATE user SET lastlogin= ':lastlogin' where userID =  ':username'";
            $query_params2 = array(  
                ':lastlogin' =&gt; $timestamp,
               ':username' =&gt; $_POST['useridforlogin']
               ); 
              try {  
                $stmt2 = $db-&gt;prepare($query2); 
                $result2 = $stmt2-&gt;execute($query_params2); 
            }  catch(PDOException $ex){ die("Failed to run query: " . $ex-&gt;getMessage()); }     
</code></pre>