Skip to content Skip to sidebar Skip to footer

Android Studio Isn't Communicating To My Php Script

I have a 2 java scripts that should go to a php file located on http://localhost/phptesting/Register.php. My script's URL links it, but when I send a register request, nothing happ

Solution 1:

I see at least two errors on this code:

privatestaticfinalStringREGISTER_REQUEST_URL="http://localhost/phptesting/Register.php";

Android doesn't like localhost you can read it here.

Best option is to do an ifconfig and get your ip address and instead of localhost put your ip address like

http://192.168.1.158/phptesting/Register.php

Also your localhost should have a port, right? So make sure you add it just in case in your BASE_URL, so it should look like this

http://192.168.1.158:8080/phptestig/Register.php

Then the call should work.

Then I see another problem with

mysqli_stmt_bind_param($statement, "siss",$username,$password,$isAdmin);

You are passing 4 values to an insert that requires 3.

I recommend you to go step by step, first make sure your api call is registering something (you can use PostMan or ARC to do it) and then go to Android side.

Post a Comment for "Android Studio Isn't Communicating To My Php Script"