Data not reaching the database

hii everyone i've been working on nodemcu and taking ultrasonic sensor values from serial monitor of arduino uno's serial monitor and trying to send the data from node mcu to my created database by WAMP but the values are not reaching at the database help me with that

HERE IS THE NODE MCU CODE
#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h>
char ssid[] = "Nodemcu";
char pass[] = "yonexcarbonex";
const char* host = "192.168.43.57";
void setup() {

Serial.begin(115200);

while (!Serial) {
;
}
WiFi.begin(ssid, pass);

while (WiFi.status() != WL_CONNECTED) {

delay(500);
Serial.println("Waiting for connection");
}
Serial.println("WiFi connected");
Serial.println("IP Address");
Serial.println(WiFi.localIP());
}
void loop() {
if (Serial.available()) {
Serial.read();
}

String postData;
String val = String (Serial.read());
if (WiFi.status() == WL_CONNECTED) {
Serial.println("connected");
HTTPClient http;
http.begin("http://192.168.43.57/UltraValues/index.php");
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
postData = "inches" + val;
// getData = "inches" + val;
// Link = "http://192.168.56.1:3306/UltraValues/index.php" + getData;
// http.begin(Link);
int httpCode = http.POST(postData);
String payload = http.getString();

Serial.println(httpCode);
Serial.println(payload);

http.end();
}]
}
else {

Serial.println("Error in WiFi connection");

}

delay(30000);
}

HERE IS THE PHP CODE

<?php //Creates new record as per request //Connect to database $servername = "localhost"; $username = "root"; $password = ""; $dbname = "ultravalue"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Database Connection failed: " . $conn->connect_error); } else { echo "Connected"; } if(!empty($_POST['val'])) { $val = $_POST['val']; $sql = "INSERT INTO value (val) VALUES ('$val')"; if ($conn->query($sql) === TRUE) { echo "OK"; } else { echo "Error: " . $sql . " " . $conn->error; } }else{ echo "Value not going"; } $conn->close(); ?>

ultrasonictonodemcu.ino (1.28 KB)

index.txt (807 Bytes)

I would test my HTTP Server endpoint from something other than my Arduino to see that my endpoint is working as it should. Then work on the Arduino code to use that endpoint. You can use a web browser to test your endpoints with a GET request by typing the URI in the location bar.

Once you are sure your endpoint is responding properly to your requests, you can then concentrate on making your Arduino sketch properly make an HTTP request.

If you want to test a post request you can get a REST client to do more advanced HTTP requests. I use Advanced REST Client.

  String val = String (Serial.read());

The read() method returns an int. That int contains an error bit (the high order bit) and 8 bits of meaningful data (i.e. at most one character). What is actually in val after this code executes?

    postData = "inches" + val;

Why is the string "inches" jammed up against the probably meaningless data in val?