Android Question My SQL Android issue with PHP file

pin71

Member
Licensed User
Longtime User
Hi,

I'm using Erel tutorial Android to My SQL to connect to my DB. The various querys work well but when I'm sending an query to UPDATE a field, I'm getting back always the same response no matter if the record exist or not.
How can I discriminate a succesfull query from a query that didn't work?
Thanks
 

mangojack

Expert
Licensed User
Longtime User
You really need to supply more information for any one to help ..

.. what is the "same response you allways receive".
.. show b4a code involved in the Update call.
.. show the corresponding PHP update code .
 
Upvote 0

pin71

Member
Licensed User
Longtime User
OK,

This is the query I use to UPDATE a record :

B4X:
ExecuteRemoteQuery("UPDATE Users SET `MBSN` = '" & MBSN  & "' WHERE Serial = '" & NS & "'", NS)

And it does the job perferctly. It update the field and after that I get as a response []. The problem is that I get the same response [] even if the record doesn't exist.
It doesn't give me back and error saying that the field is not present in the database.

The php file is the one from the tutorial, here it is :

B4X:
<?php

$databasehost = "xx.xx.xx.xx";
$databasename = "dbname";
$databaseusername ="user";
$databasepassword = "psw";

$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);
?>
 
Upvote 0
Top