While writing data in MySQL through PHP, add current date and time -
i'm gathering info website put in mysqldatabase. @ moment cannot find out how date , time in database.
i tried several things, can help?
$write="replace `".$database."`.`db` (`1`,`2`,`3`,`4`,`5`,`6`,`7`,`datetime`) values ('".$1."','".$2."','".$3."','".$4."','".$5."','".$6."','".$7."','**so need place here**')"; echo $write; $query = mysql_query($write) or die (mysql_error());
in database no matter put in php, 0000-00-00 00:00:00.
just passed value now()
, example
insert tb(col1) values(now())
as sidenote, query vulnerable sql injection
if value(s) of variables came outside. please take @ article below learn how prevent it. using preparedstatements
can rid of using single quotes around values.
Comments
Post a Comment