Android Question PHP script with Parameters not working

erasmusackon

Member
Licensed User
Longtime User
This code is able to retrieve records from the server
B4X:
    $q = mysqli_query($con,"SELECT * FROM DepositTransactions");
    $rows = array();
    while($r = mysqli_fetch_assoc($q))
    {
    $rows[] = $r;
    }
    echo json_encode($rows);
    mysqli_close($con);

GetTransactions is unable to work. it returns [] when i checked the log. Am i doing anything wrong in this "GetTransactions"

B4X:
    Dim DownloanTransactions As HttpJob
    DownloanTransactions.Initialize("DownT", Me)
    DownloanTransactions.Download2(Server, Array As String ("action", "GetTransactions","memberID",MemberID,"lasttrans",LastTransID))

B4X:
$action = $_GET["action"];

switch ($action)

{
    case "CountPersons":
        $q = mysqli_query($con,"SELECT * FROM DepositTransactions WHERE MemberID=40001762");
        $count = mysqli_num_rows($q);
        print json_encode($count);
        mysqli_close($con);
    break;
  
    Case "GetTransactions":
        $memberid = $_GET["memberid"];
        $lasttrans = $_GET["lasttrans"];
        $q = mysqli_query($con,"SELECT * FROM DepositTransactions WHERE MemberID=$memberid AND TranNo>$lasttrans");
        $rows = array();
        while($r = mysqli_fetch_assoc($q))
        {
        $rows[] = $r;
        }
        print json_encode($rows);
        mysqli_close($con);
    break;
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
why not assist?
I posted a really good PHP 7 Compatible Class and a sample on how to work with this Class. For sure it is not a complete use but it shows the main usage.
Correctly used you dont need to take care about escaping vars. The class do all this.

BUT you are now using simple mysqli methods. So you need to get familar will all of them.
There are a lot of documentation on the php site about all of them. Including userhints. Start reading there.

I guess you should google for some tutorials on how to use the mysqli methods correctly.

I cant help on this. I never used them.
 
Upvote 0

erasmusackon

Member
Licensed User
Longtime User
Thanks@DonManfred. When I use the class you gave me the connection to the server fails. Am still learning from you class and picking one or two from there. Will do more reading as recomemded.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…