I have been working on one of my android project and today I am facing an error. Here I am trying to update some values in table through php. But I am getting error like “E/Volley: [17118] NetworkUtility.shouldRetryException: Unexpected response code 500” . I am using volley library in android with java language.
Here is my php code :
`<?php
$qid = $_POST['qId'];
$ans = $_POST['ans'];
include "W_config.php";
$sql="SELECT * FROM `$db`.`user_ques` WHERE `id`= 49";
$result=mysqli_query($conn,$sql);
if(mysqli_num_rows($result)>0){
while($row=mysqli_fetch_array($result)){
$answer = $row['7'];
if($ans == 0){
$new = $answer-1;
$sql="UPDATE `$db`.`user_ques` SET `answers`='{$new}' WHERE `id`= 49";
$result=mysqli_query($conn,$sql) or die("result failed");
//echo "yes";
}else{
$new = $answer+1;
$sql="UPDATE `$db`.`user_ques` SET `answers`='{$new}' WHERE `id`= 49";
$result=mysqli_query($conn,$sql) or die("result failed");
//echo "no";
}
}
}
?>`
Here the strange thing is that when I am commenting the if else part it is working fine and if I am directly running it on browser then also it is working fine but when connected with android project it is not working .
Here is my java code
`public void updateQuesAnsNo(int ans){
final String proIdd = String.valueOf(qId);
final String ansType = String.valueOf(ans);
StringRequest request = new StringRequest(Request.Method.POST, url7, new
Response.Listener<String>() {
@Override
public void onResponse(String response) {
progressDialog.dismiss();
getAnswers(page);
SharedPreferencelogin session = new SharedPreferencelogin(questionDetailPage.this);
int sessionId = session.getSession();
getUserDetails(proUserId);
if(sessionId != proUserId){
addAnsNotification();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
})
{
@Override
protected Map<String, String> getParams() {
Map<String,String> map=new HashMap<String, String>();
map.put("qId",proIdd);
map.put("ans",ansType);
return map;
}
};
RequestQueue queue = Volley.newRequestQueue(questionDetailPage.this);
queue.add(request);
}`
Here this function is also correct as I have tested it with another url and it is working fine. Please solve it.`
I was trying to update the values in table but is is giving me error like “E/Volley: [17118] NetworkUtility.shouldRetryException: Unexpected response code 500”
prashnika is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.