Im trying to update some data in a mysql database that i made in this webhost.
I made this php code and manually tested it with my browser and it works.
<?php
//Database login variables
$dbusername = "id5096752_root";
$dbpassword = "***";
$host = "localhost";
$mydb = "id5096752_disspill";
//Connect to database
$con = new mysqli ($host, $dbusername, $dbpassword);
if($con)
{
echo "Connection succesful";
}
else
{
echo "Connection error";
}
mysqli_select_db($con,$mydb) or die
("Database selection error");
//Query
$SQL = "UPDATE contenedores SET ocupado='$_GET[ocupado]', nombrePastilla='$_GET[nombrePastilla]', cantidadPastillas = '$_GET[cantidadPastillas]' WHERE numeroContenedor = '$_GET[numeroContenedor]'";
//Execute query
mysqli_query($con,$SQL);
?>
Im trying to code it into arduino. Here is the important parts of the code:
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x19 };
char bdServer[] = "disspill.000webhostapp.com";
...
Ethernet.begin(mac);
client.stop();
Serial.println("Connecting with BD");
if(client.connect(bdServer, 80))
{
Serial.println("Connected");
client.print("GET /phpcommands/updateData.php?numeroContenedor=1&ocupado=si&nombrePastilla=paracetamol&cantidadPastillas=7");
client.println(" HTTP/1.1");
client.println("Host: disspill.000webhostapp.com");
client.println("Connection: close");
client.println();
client.stop();
}
else
{
Serial.println("Error");
}
Aparently it does connect to the server, but the data doesnt update. Does somebody know what is wrong?