數組和商店回報,我想一個PHP陣列作爲存儲在MySQL JSON
。爲此我有meeting_point_json
列,type ='longtext'。PHP json_encode在MySQL
這裏是數組:
Array
(
[1] => Array
(
[date] => 23/4/2012
[meeting_time] => 23:04
[meeting_place] => town hall
[venue] => London
[opponents] => Tigers
[official_incharge] => Mr Putin
)
[2] => Array
(
[date] => 23/4/2050
[meeting_time] => 13:04
[meeting_place] => chief office
[venue] => Kenya
[opponents] => Peococks
[official_incharge] => Mr Black
)
[3] => Array
(
[date] => dsad
[meeting_time] => sadas
[meeting_place] => jjjjj
[venue] => jjjj
[opponents] => dasds
[official_incharge] => asad
)
)
這裏是PHP代碼:
$data = json_encode($_POST['team_meeting_pt']);
$sql = "UPDATE yami_sub_team set meeting_point_json = $data where id = $subteam_id";
if(mysql_query($sql)){
exit("Done!");
}else{
die('Something went wrong, changes not saved. Error details: ' . mysql_error());
}
它應該工作,但取而代之的是,我得到一個錯誤:
Something went wrong, changes not saved. Error details: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"1":{"date":"23\/4\/2012","meeting_time":"23:04","meeting_place":"town hall","ve' at line 1
任何想法我在這裏做錯了什麼?
什麼的$數據的全部價值? –
如果_POST [''team_meeting_pt]是空的或更糟的是NOT SET? – Svetoslav
@Svetlio或者更糟的是,試圖破解他的數據庫? :) –