开发者

posting array to MySQL

How can insert a array into my MySQL database?

I have managed to insert some of this data into the database already.

Below is part of my code:

$depart=开发者_高级运维serialize($_POST['departure']); 
$sql="INSERT INTO bookings VALUES('$depart');

I am trying to insert

[departure] => Array ( [0] => 30 [1] => 05 [2] => 2011 [3] => 17 [4] => 41 )

into the database field 'depart'

your help will be much appreciated.


Assuming 'depart' is a datetime field:

$timestamp = mktime($depart[3], $depart[4], 0, $depart[2], $depart[1], $depart[0]);

$sql = "insert into bookings(depart) values (from_unixtime($timestamp))";

// Execute the sql as normal


You should escape your serialized array string.

$depart=mysql_real_secape_string(serialize($_POST['departure']));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜