title: How to update time in mySql database using php
body: <p>I am trying to update time in mysql database using php on clicking of button. I am using the following query:</p>
  
  <pre><code>update tableName SET Time=CURTIME() where Uname='$uname1' AND Password = '$password'
  </code></pre>
  
  <p>This query is not working. But If I hard code this query, this will work fine. I am not getting any idea about this why Its not working. Here is my complete php code :</p>
  
  <pre><code>&lt;?php
  $host='localhost';
  $uname='root';
  $pwd='password';
  $db='database';
  
  $con=mysql_connect($host,$uname,$pwd) or die("Connection Failed");
  mysql_select_db($db,$con) or die("database selection failed");
  
  $uname1 = mysql_real_escape_string($_POST['Uname']); # Secure the input!
  $password = mysql_real_escape_string($_POST['Password']);
  $time = strtotime(exec("date"));
  
  $flag['code']=0;
  
  $select=("update Insert1 SET Time=CURTIME() where Uname='$uname1' AND BINARY Password = BINARY '$password'" );
  //$select=("select * from Insert1 where Uname = '$uname1' AND BINARY Password = BINARY '$password'" );
  
  $r=mysql_query($select,$con);
  
  if(mysql_num_rows($r) &gt; 0) { 
     $flag['code']=1;
  }
  print(json_encode($flag));
  mysql_close($con);
  ?&gt;
  </code></pre>