title: How to insert the current timestamp into MySQL database using a PHP insert query
body: <p>In my MySQL database, I have a table with structure</p>
  
  <pre><code>username - varchar
  insert_time - timestamp
  </code></pre>
  
  <p>This table was created in MySQL using the phpMyAdmin tool and for the <code>insert_time</code> column, I have mentioned default value as <code>0000-00-00 00:00:00</code>.</p>
  
  <p>Now the problem is, I have to update this default value with the current timestamp later on, using a PHP script.</p>
  
  <p>I tried doing the following PHP code:</p>
  
  <pre><code>$update_query = 'UPDATE db.tablename SET insert_time=now() '.
                  'WHERE username='.$somename;
  </code></pre>
  
  <p>When the PHP script is run, it fails, and is unable to insert anything into the database.</p>
  
  <p>What am I doing wrong?</p>