JSON
mysqlのようにphp配列を保存したい。そのためにmeeting_point_json
、type='longtext' の列があります。
ここに配列があります:
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
私がここで間違っていることは何か分かりますか?