I am a newbie. I started php coding few days back. I want to copy a "datetime" datatype in php to fields that are of "date" and "time" datatype.
I have kept the field name datetime_info for the datetime value. It exists in try1 table. date is the name of field for "date" datatype and time is the name for "time" datatype. These two exist in try2 table.
Here is what I have written.
$result = mysql_query("SELECT * FROM try1");
while ($row = mysql_fetch_array($result))
{
$result_update = mysql_query("INSERT INTO try2 (date, time) VALUES ('".$row_team['datetime_info']."', '".$row_team['datetime_info']."')");
if (!$result_update)
die('Error: ' . mysql_errno() . mysql_error());
}
The values stored in "try1" table are:
id datetime_info
1 2008-10-02 00:00:00
2 2008-10-09 00:00:00
The expected response should be the date and time stored in respective fields. However, the output is
id date time
2 0000-00-00 00:00:00
3 0000-00-00 00:00:00
Can anyone explain me why and how? I tried a lot of sites but did not find any proper explanation for this. Thank you in anticipation.
Regards, BasicGem
MySQLiphp.net/manual/en/book.mysqli.php