Sending data to a MySQL Database

Hey! I'm making a program in MIT App Inventor that accepts some data (An image in base 64 encoding, a userid (which is a number) and a list with checklists (accepting either 0 or 1)) and sends a post request to send the data to a MySQL database. Here's my code (not the full code):

(The web1 url is blurred out but it's an insert.php link)
I got an error 1117 (timeout error) as it wasn't connecting to the database

so what's your question? did you get any error?

I got an error 1117 (timeout error) as it wasn't connecting to the database (I edited my post to add this) Basically the app connects to an insert.php file which connects to a database. I know that both insert.php and the database were working fine since i managed to connect it with my ios app, so i know that there must be an error with this code.

can you post data with postman?

How do I use postman with MIT App Inventor? I'm currently using HTTP Post request. I already have an insert.php being used as the api to connect the database with my app.

test the api with help of postman. not in app Inventor

What do you mean? You can test the API with Postman?

Google postman, you will know what it is for.

and your Request Headers have a empty socket. and the KeepAlive is necessary?

and show us the insert.php , may help us to help you .

I already have the framework for the connection, I think i just have an error in my MIT App Inventor Code. The empty socket was just for testing something else, i had the error even without the empty socket. Right now im testing with a public database, but when i was testing with my own local host, the connection KeepAlive fixed my issue with localhost.
Here is the insert.php (Although i'm pretty sure it's working:)


// set up the response array
$response = array();

// check if the request method is POST

  // get the userid from the POST request
  $userid = $_POST['userid'];
 $imagekey = $_POST['imagekey'];
 $glad = $_POST['glad'];
$delighted = $_POST['delighted'];
$overjoyed = $_POST['overjoyed'];
$competent = $_POST['competent'];
$proud = $_POST['proud'];
$daring = $_POST['daring'];
$accepted = $_POST['accepted'];
$valued = $_POST['valued'];
$admired = $_POST['admired'];
$liked = $_POST['liked'];
$loved = $_POST['loved'];
$adored = $_POST['adored'];
$alone = $_POST['alone'];
$lonely = $_POST['lonely'];
$isolated = $_POST['isolated'];
$slighted = $_POST['slighted'];
$disrespected = $_POST['disrespected'];
$humiliated = $_POST['humiliated'];
$letdown = $_POST['letdown'];
$disappointed = $_POST['disappointed'];
$crushed = $_POST['crushed'];
$uncertain = $_POST['uncertain'];
$weak = $_POST['weak'];
$helpless = $_POST['helpless'];
$lost = $_POST['lost'];
$hopeless = $_POST['hopeless'];
$suicidal = $_POST['suicidal'];
$unhappy = $_POST['unhappy'];
$sad = $_POST['sad'];
$miserable = $_POST['miserable'];
$annoyed = $_POST['annoyed'];
$frustrated = $_POST['frustrated'];
$furious = $_POST['furious'];
$upset = $_POST['upset'];
$bitter = $_POST['bitter'];
$indignant = $_POST['indignant'];
$worried = $_POST['worried'];
$threatened = $_POST['threatened'];
$terrified = $_POST['terrified'];
$otheremotion = $_POST['otheremotion'];

  echo $userid;

  // connect to the database
  require_once "config.php";

  // insert the record into the database
  $sql = "INSERT INTO stardata (userid, imagekey, glad, delighted, overjoyed, competent, proud, daring, accepted, valued, admired, liked, loved, adored, alone, lonely, isolated, slighted, disrespected, humiliated, letdown, disappointed, crushed, uncertain, weak, helpless, lost, hopeless, suicidal, unhappy, sad, miserable, annoyed, frustrated, furious, upset, bitter, indignant, worried, threatened, terrified, otheremotion) VALUES (:userid, :imagekey, :glad, :delighted, :overjoyed, :competent, :proud, :daring, :accepted, :valued, :admired, :liked, :loved, :adored, :alone, :lonely, :isolated, :slighted, :disrespected, :humiliated, :letdown, :disappointed, :crushed, :uncertain, :weak, :helpless, :lost, :hopeless, :suicidal, :unhappy, :sad, :miserable, :annoyed, :frustrated, :furious, :upset, :bitter, :indignant, :worried, :threatened, :terrified, :otheremotion)";
  $stmt = $pdo->prepare($sql);
  $stmt->bindParam(':userid', $userid);
 $stmt->bindParam(':imagekey', $imagekey);
 $stmt->bindParam(':glad', $glad);
 $stmt->bindParam(':delighted', $delighted);
 $stmt->bindParam(':overjoyed', $overjoyed);
 $stmt->bindParam(':competent', $competent);
 $stmt->bindParam(':proud', $proud);
 $stmt->bindParam(':daring', $daring);
 $stmt->bindParam(':accepted', $accepted);
 $stmt->bindParam(':valued', $valued);
 $stmt->bindParam(':admired', $admired);
 $stmt->bindParam(':liked', $liked);
 $stmt->bindParam(':loved', $loved);
 $stmt->bindParam(':adored', $adored);
 $stmt->bindParam(':alone', $alone);
 $stmt->bindParam(':lonely', $lonely);
 $stmt->bindParam(':isolated', $isolated);
 $stmt->bindParam(':slighted', $slighted);
 $stmt->bindParam(':disrespected', $disrespected);
 $stmt->bindParam(':humiliated', $humiliated);
 $stmt->bindParam(':letdown', $letdown);
 $stmt->bindParam(':disappointed', $disappointed);
 $stmt->bindParam(':crushed', $crushed);
 $stmt->bindParam(':uncertain', $uncertain);
 $stmt->bindParam(':weak', $weak);
 $stmt->bindParam(':helpless', $helpless);
 $stmt->bindParam(':lost', $lost);
 $stmt->bindParam(':hopeless', $hopeless);
 $stmt->bindParam(':suicidal', $suicidal);
 $stmt->bindParam(':unhappy', $unhappy);
 $stmt->bindParam(':sad', $sad);
 $stmt->bindParam(':miserable', $miserable);
 $stmt->bindParam(':annoyed', $annoyed);
 $stmt->bindParam(':frustrated', $frustrated);
 $stmt->bindParam(':furious', $furious);
 $stmt->bindParam(':upset', $upset);
 $stmt->bindParam(':bitter', $bitter);
 $stmt->bindParam(':indignant', $indignant);
 $stmt->bindParam(':worried', $worried);
 $stmt->bindParam(':threatened', $threatened);
 $stmt->bindParam(':terrified', $terrified);
$stmt->bindParam(':otheremotion', $otheremotion);


  // set the success message in the response array
  $response['error'] = false;
  $response['message'] = 'Record inserted successfully';
} else {
  // set the error message in the response array
  $response['error'] = true;
  $response['message'] = 'You are not authorized';


// return the response as JSON
echo json_encode($response);

// close the database connection

csn you do this and tell us the result?