Hi, I have a problem to send data to mysql database in xampp localhost using arduino ethernet shield. After i upload the sketch to my arduino, i think my arduino have connected to my pc, but my database data don't get any change. This is my arduino sketch:
#include <SPI.h>
#include <Dhcp.h>
#include <Dns.h>
#include <Ethernet.h>
#include <EthernetClient.h>
#include <EthernetServer.h>
#include <EthernetUdp.h>
byte mac[] = {
0xDE,0xAD,0xBE,0xEF,0xFE,0xED
};
IPAddress ip(192, 168, 1, 177);
//IPAddress gateway(192, 168, 1, 10);
IPAddress server(192, 168, 1, 10);
EthernetClient client;
int a = 320;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Ethernet.begin(mac,ip);
}
void loop() {
// put your main code here, to run repeatedly:
if (client.connect(server,80)) {
//Serial.println("connected");
client.print("GET/update.php?id=2&temp=");
client.print(a);
client.println("HTTP/1.1");
client.println("Host:192.168.1.10");
client.println("Connection Close");
client.println();
client.println();
client.stop();
}
else {
Serial.println("Connection failed\n");
}
delay(10000);
}
I hope that anyone could help me to solve this problem. Thanks a lot.