I am having a problem with the last comma when I am using PHP echoing JSON Array to android
Here is my code
If ($commentResult>0)
echo "[";
{
while ($row = mysql_fetch_array($commentResult)) {
echo json_encode($row).",";
}
echo "]";
Android can’t read this, it printed out JSONException:Vale at 3 is null
Why are you trying to re-invent the wheel? If you want to give an entire array then put json_encode over the entire array instead of trying to manually build it.
*Also, a side tip, don’t use mysql_ functions. Instead use PDO or mysqli, which are better supported and get you rid of this whole while($row) business.*