I'm using a Serial to WiFi module which are able to send HTTP. I have made a sketch to update a Table in MySQL with a PHP script. My problem is, I'm not able to update the Table when using variables. It works fine with static values. I want to know if there is a problem in the Arduino sketch or the way to use the HTTP command.
Look at lines below from loop() and PHP script also:
float tm = 21.8;
Serial.write("AT+HTTPPH=/update1x.php?tmp=tm\n"); // Parse values to PHP script
If I insert the value 21.8 instead of variable tm, it works.
<?php
$aa = (isset($_GET['tmp']) ? $_GET['tmp'] : null);
mysql_connect('my.dk.mysql','my_dk','my_pw') or die("Can't connect that way!");
@mysql_select_db('my_dk') or die("Unable to select a database called 'My'");
date_default_timezone_set("Europe/Copenhagen");
$dat = date("Y-m-d");
$tim = date("H:i:s");
$qry = "INSERT INTO temp1(temp, date, time) VALUES('$aa','$dat','$tim')";
mysql_query($qry);
mysql_close();
exit('OK');
?>