Question : php mysql storing date time

Hello experts,
HOw can I store the php variable $w_dat_tim in a mysql table?
See code below. the insert does not work....
Regards,
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
<?
  $db   = mysql_connect("localhost","database","pwd");
  mysql_select_db("beta",$db);
  
  $t2 = strtotime("+1 hour");
  $w_dat_tim = date("Y-m-d H:i:s",$t2);

  $q = " insert into tbl_0_lic_act (  dat_tim  )  values (  $w_dat_tim ) " ;
  
  $x = mysql_query($q,$db);

  mysql_close($db);
  
?>

Answer : php mysql storing date time

What is the error?
If you don't know try inserting "die"s and "echo"s into the code and see where you fail:

<?
  $db   = mysql_connect("localhost","database","pwd") or die("cold not connect");
  mysql_select_db("beta",$db) or die("could not select db");
 
  $t2 = strtotime("+1 hour");
  $w_dat_tim = date("Y-m-d H:i:s",$t2);

  $q = " insert into tbl_0_lic_act (  dat_tim  )  values (  $w_dat_tim ) " ;
  echo "q"; //check if the insert is what you expected
   
  $x = mysql_query($q,$db) or die("Could not insert data");

  mysql_close($db);
 
?>
Random Solutions  
 
programming4us programming4us