Android Question 411 Length Required

Che Mohamad

Member
Licensed User
Hello,
My apps has been running fine more than 1 year. The connection from the apps is made to the mysql in remote server based on the tutorial by Erer here
However since this morning we have problem getting the reply from the server whenever we sent the mysql query (as per attached file)
After some googling, I am convinced that the solution is to add "Content Length in HTPP header".
The problem is, based on the Erel tutorial, how do I add this into the "countries.php" file? or where exactly do I add this?

Connect To MySql:
<?php

$databasehost = "localhost";
$databasename = "xxxx";
$databaseusername ="xxxx";
$databasepassword = "xxxx";

$con = mysqli_connect($databasehost,$databaseusername,$databasepassword, $databasename) or die(mysqli_error($con));
mysqli_set_charset ($con , "utf8");
$query = file_get_contents("php://input");
$sth = mysqli_query($con, $query);

if (mysqli_errno($con)) {
   header("HTTP/1.1 500 Internal Server Error");
   echo $query.'\n';
   echo mysqli_error($con);
}
else
{
   $rows = array();
   while($r = mysqli_fetch_assoc($sth)) {
     $rows[] = $r;
   }
   $res = json_encode($rows);
    echo $res;
    mysqli_free_result($sth);
}
mysqli_close($con);
?>

Thank you for your responce.
 

Attachments

  • ContentLength Error.jpg
    185.4 KB · Views: 117

Che Mohamad

Member
Licensed User
How is the error related to the PHP-Script? The error is in your appcode.
You are not posting any code here. I don´t see how we could help.
As I mentioned , the app was running without problem for more than a year and we didnt change anthing since then.
Only this morning its showing the error. Thanks
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
Are you using jOkHttpUtils2? The content length is added automatically.

My guess is that something changed on the server side, maybe a proxy.
maybe PHP version. it happens also to me. they update the php version and my app start making problems and i need to fix it.
i also think it has something to do on the server side.
 
Upvote 0

Che Mohamad

Member
Licensed User
Are you using jOkHttpUtils2? The content length is added automatically.

My guess is that something changed on the server side, maybe a proxy.
Yes I am using OkHttpUtils2. Glad to know that its been added.
I asked the hosting provider to revoke whatever they have done on the server during the weekend (as usual they like to do chages during weekend and expect Monday blues the next day )
The problem has been resolved but without a lesson learnt : we don't know what exactly has been changed on the server. I checked on the PHP version they didn't upgrade that.
Anyway the problem has been resolved for now. Thanks.
 
Upvote 0

Che Mohamad

Member
Licensed User
maybe PHP version. it happens also to me. they update the php version and my app start making problems and i need to fix it.
i also think it has something to do on the server side.
They didnt upgrade the PHP version but the problem has been resolved. I still dont know what changed has been made during weekend.
So problem has been resolved but no lesson learnt. Thank you for your reply.
Question : How do I mark this post as "SOLVED" ?
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…