Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Someone help me out, I\'ve been working on this code for 4 hours. Here\'s the sc

ID: 3936789 • Letter: S

Question

Someone help me out, I've been working on this code for 4 hours.

Here's the scenario.

I am posting String data from an android app I am developing to an sql database.

I am able to 'echo' all of the POST data from the PHP to the android app, so I am fairly confident that the java is solid.

But heres the thing that baffles me...

When I change the $POST["username"] to "andrewnguyen22" it works fine...

Below I have posted my PHP and my Java. Please help

PHP CODE:

require "conn.php";
$username = $_POST["username"];
$fullName = $_POST["fullName"];
$age =$_POST["age"];
$bio =$_POST["bio"];
$year =$_POST["year"];
$gender =$_POST["gender"];
$location =$_POST["location"];
$sql = "UPDATE user_info SET fullName ='$fullName', bio='$bio', age='$age', gender='$gender', location='$location', year='$year' WHERE username = '$username' ";
$do = mysqli_query($conn, $sql);
if(mysqli_affected_rows($conn) >0){
echo 0;
}
else{
   echo $username;
}  
?>

Android App Code Snippet:

So when the code fails. It displays my username correctly on my android emulator... (through the alert dialog if else on postexecute0

Explanation / Answer

Hello,

You code seems to be fine. Instead of $POST["username"] , could you please hard-code any username and try running the code again. OR, please use the keyword userid instead of username, and see if that works fine for you.

Hope this helps..