Hi, my first topic here.. i have sensor and ESP32 programmed to send data from sensor to mit app inventor, i want to send it from app to mysql base , my data is not inserted in mysql database.. i tried veryy much posibilities to do this. can you help?
<?php
define('DB_USER', 'root');
define('DB_PASSWORD', '');
define('DB_HOST', '127.0.0.1');
define('DB_NAME', 'heart_rate_data');
// Establish the database connection
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if (!$dbc) {
die("DATABASE CONNECTION FAILED: " . mysqli_connect_error());
}
$dbs = mysqli_select_db($dbc, DB_NAME);
if (!$dbs) {
die("DATABASE SELECTION FAILED: " . mysqli_error($dbc));
}
if (isset($_GET['bpm'])) {
$bpm = mysqli_real_escape_string($dbc, $_GET['bpm']);
$query = "INSERT INTO bpm_readings (bpm) VALUES ('$bpm')";
if (mysqli_query($dbc, $query)) {
echo "Records added successfully.";
} else {
echo "ERROR: Could not able to execute $query. " . mysqli_error($dbc);
}
} else {
echo "No data received.";
}
mysqli_close($dbc);
?>`