我是 Android 开发的新手。我正在将 JSON 数据从 Android 发送到我的 PHP 服务器。但我收到一个错误:
Error parsing data org.json.JSONException: Value `<br` of type java.lang.String cannot be converted to JSONObject".
这是我的 PHP 代码:
<?php
$con = mysql_connect("localhost","custome234r","reswtdf123");
if (!$con)
die('Could not connect: ' . mysql_error());
mysql_select_db("customer_dd_test", $con);
$jsonFeedbackResult = $_REQUEST['results'];
$flagToOpenTicket = false;
$arrResult = json_decode(stripslashes_deep($jsonFeedbackResult));
$feedbackname = $arrResult[0]['feedbackname'];
$email = $arrResult[0]['email'];
unset($arrResult[0]);
$finalArray = array_values($arrResult);
foreach($finalArray as $key => $arrQuestionWithAnswer)
{
if($arrQuestionWithAnswer['answer'] == 'bad' || $arrQuestionWithAnswer['answer'] == 'worst')
{
$flagToOpenTicket = true;
break;
}
}
if($flagToOpenTicket)
{
$insertQuery = 'INSERT INTO dev_ticket(email, feedbackname) VALUES';
$insertQuery .= '("'.$email.'", "'.$feedbackname.'"),';
$executeQuery = trim($insertQuery,',');
mysql_query($executeQuery);
}
mysql_close($con);
print(json_encode(array('response'=>$feedbackname)));
?>