0

Some times not saving date time buy
I am inserting date and time, but storing 0000-00-00 00:00:00

Here is the code
<?php
include("connect_mysql.php");
$date=date("Y-m-s H:i:s");
mysql_query("insert into buy_db (from_site, date_time_buy, model, ip) values ('".$_REQUEST."', '$date','".$_REQUEST."', '".$_REQUEST."')");
//header('Location:'.$_REQUEST);
?>

Attachment including:
1. Data in Table
2. Table Structure

Attachments some_times_not_saving_date_time_buy.png 87.16 KB table_structure.png 19.28 KB
3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by vibhaJ
0

just try this:
mysql_query("insert into buy_db (from_site, date_time_buy, model, ip) values ('".$_REQUEST."', '".$date."','".$_REQUEST."', '".$_REQUEST."')");

0

If data type is timestamp it will automatically take current datetime.
You don't need to add it in insert query.

<?php
include("connect_mysql.php");
$date=date("Y-m-s H:i:s");
mysql_query("insert into buy_db (from_site, model, ip) values ('".$_REQUEST['site']."', '".$_REQUEST['model']."', '".$_REQUEST['ip']."')");
//header('Location:'.$_REQUEST['url']);
?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.