I'm new to php and dealing with databases. I have accomplished sending data from one arduino sensor to the database using PHP and XAMPP. My problem is sending data from multiple sensors.
The PHP code in file "write_data_w2"
<?php
$dbusername = "w123";
$server = "localhost";
$dbconnect = mysqli_connect($server, $dbusername);
$dbselect = mysqli_select_db($dbconnect,"weather1");
$sql = "INSERT INTO weather1.weather (temperature, humidity, rain) VALUES ('".$_GET["temperature"].",".$_GET["humidity"].",".$_GET["rain"]."')";
mysqli_query($dbconnect, $sql);
?>
I'm not using a password for the user "w123".
I wanted to check everything and tried inserting some made up data through browser with "http://localhost/write_data_w2.php?temperature=32&humidity=45&rain=N"
and nothing happens, no warnings, no errors, no data. The database stays empty.
The database is named "weather1" consists of 1 table named "weather" and 5 columns named: "id", "time", "temperature", "humidity", "rain".
Solved
As a user suggested I added the line:
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
which displayed some errors that I then solved.
I also had to modify "$sql" a bit:
$sql = "INSERT INTO weather1.weather (temperature, humidity, rain) VALUES ('".$_GET['temperature']."', '".$_GET['humidity']."', '".$_GET['rain']."')";