Hello everyone,
I have an application on my Android with select and insert statement on MySQL database over .php script on my server. When I do a SELECT statement everything is working perfect. When I do an INSERT statement I get an error in B4A logs wich occurs occasionally.
ResponseError. Reason: Internal Server Error, Response: PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in C:\inetpub\wwwroot\GetDataSQL_B4A.php on line 21
PHP Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in C:\inetpub\wwwroot\GetDataSQL_B4A.php on line 26
My php code in GetDataSQL_B4A.php is:
Why Am I getting this error?
I have an application on my Android with select and insert statement on MySQL database over .php script on my server. When I do a SELECT statement everything is working perfect. When I do an INSERT statement I get an error in B4A logs wich occurs occasionally.
ResponseError. Reason: Internal Server Error, Response: PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in C:\inetpub\wwwroot\GetDataSQL_B4A.php on line 21
PHP Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in C:\inetpub\wwwroot\GetDataSQL_B4A.php on line 26
My php code in GetDataSQL_B4A.php is:
B4X:
<?php
$databasehost = "localhost";
$databasename = "mydatabase";
$databaseusername ="myuser";
$databasepassword = "mypass";
$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);
?>
Why Am I getting this error?