I am trying to send data from my Arduino to my database but it seems that the process is not successfully beginning. Here is my code for Arduino:
#include <Process.h>
#include <Bridge.h>
int temperature;
void setup() {
Bridge.begin(); // Initialize Bridge
}
void loop() {
int temperature = random(0, 100);
Process p;
p.begin("143.248.181.36/db.php");// 143.248.181.36 address of localhost.
p.addParameter(String(temperature));
p.run();
delay(5000);
}
And here is my PHP code:
<?php
$temperature = $argv[1];
$DBServer = '143.248.181.36';
$DBUser = 'root';
$DBPass = 'Mphav123*';
$DBName = 'dbtestardiuno';
$conn = new mysqli($DBServer, $DBUser, $DBPass, $DBName);
/ check connection
if ($conn->connect_error) {
trigger_error('Database connection failed: ' . $conn->connect_error, E_USER_ERROR);
}
$sql="INSERT INTO sensor_data (temperature) VALUES ($temperature)";
if($conn->query($sql) === false) {
trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);
}
?>
I am using xampp and I put db.php inside the htcocs folder. Can anyone point out why it does not work?