I have the following Arduino sketch that seems to be working fine
#include <SPI.h>
#include <Ethernet.h>
int bstate = 0;
String txData="";
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server(192,168,1,65);
void setup(){
delay(1000);
Ethernet.begin(mac);
Serial.begin(9600);
}
void loop(){
bstate++;
txData = (String(bstate));
EthernetClient client;
if(client.connect(server, 80)){
delay(100);
Serial.println("Connected to ego...");
Serial.println();
client.print("GET localhost/ego/WebContent/test.php?num=");
client.print(txData);
client.print(" HTTP/1.1");
client.println(" HOST: localhost");
client.println(" Connection: close");
client.println("");
Serial.println("data sent");
}
else{
Serial.println("Connection Failed.");
Serial.println();
}
delay(5000);
}
However, I am not seeing any changes reflected in the database.
Here is test.php:
Here is the Apache access.log:
192.168.1.92 - - [13/Mar/2014:21:23:49 -0700] "GET localhost/ego/WebContent/test.php?num=1 HTTP/1.1 HOST: localhost" 400 979 "-" "-"
192.168.1.92 - - [13/Mar/2014:21:23:54 -0700] "GET localhost/ego/WebContent/test.php?num=2 HTTP/1.1 HOST: localhost" 400 979 "-" "-"
192.168.1.92 - - [13/Mar/2014:21:23:59 -0700] "GET localhost/ego/WebContent/test.php?num=3 HTTP/1.1 HOST: localhost" 400 979 "-" "-"
192.168.1.92 - - [13/Mar/2014:21:24:04 -0700] "GET localhost/ego/WebContent/test.php?num=4 HTTP/1.1 HOST: localhost" 400 979 "-" "-"
192.168.1.92 - - [13/Mar/2014:21:24:09 -0700] "GET localhost/ego/WebContent/test.php?num=5 HTTP/1.1 HOST: localhost" 400 979 "-" "-"
I spent some time going over this post that describes a similar issue: [SOLVED] Arduino Ethernet write to MySQL $_GET issue PHP WAMP - Networking, Protocols, and Devices - Arduino Forum
But I still can't get it to work.