Error with implode array in php 5.3.9 -
trying create array in specific format google chart api, im getting error implode function. found exmaple im getting error ( ! ) parse error: syntax error, unexpected t_variable in c:\wamp\www\sqltest\sqltester.php on line 22 line 22 implode line, think may need quotes based on php.net says i'm doing wrong.
//your database query goes here $list = mysql_query("select city,crimes table"); while($row = mysql_fetch_assoc($list)){ $data[] = "['".$row['city']."', ".$row['crimes']."]"; } $data_for_chart = implode(",\n"$data); looking output used in google chart api
['cardiff', 300], ['london', 900], ['manchester', 500], ['dublin', 400], ['liverpool', 600] ]);
missing comma here:
$data_for_chart = implode(",\n"$data); // ---------------------------^ this should be:
$data_for_chart = implode(",\n", $data);
Comments
Post a Comment