I want to store a php array as JSON
in mysql. for that I have meeting_point_json
column with type='longtext'.
here is the array:
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
)
)
and here is the php code:
$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());
}
it should work but Instead, I get an 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
Any idea what I am doing wrong here?