简体   繁体   中英

Arduino to MySQL via phpmyadmin

EDIT: 22 Aug 2015 @ 22:44z

Hi all,

My "post" and "display" PHPs work. I've checked both of them thoroughly. I am almost certain that the fault is in the code below, I just don't know where.

The questions is "why can't the arduino/wifishield connect to a MySQL database hosted by NetSol managed by phpmyadmin?" I have the DB IP address, pass, username, etc. baked into the PHPs.

Here is the C code that I'm using:

void postData() {
if (client.connect(server, 80)) {
Serial.println("connecting...");
client.println("POST /insert_mysql.php HTTP/1.1")
//I've verified this PHP connects to the DB via the IP address
client.println("Host: www.<my_website>.com"); //hosted by NetSol
client.println("User-Agent: Arduino/1.0"); //should this be 2.0?
client.println("Connection: close");
client.println("Content-Type: application/x-www-form-urlencoded;");
client.print("Content-Length: ");
client.println(yourdata.length());
client.println();
client.println(yourdata);
} 
else {
Serial.println("Connection failed");
Serial.println("Disconnecting.");
client.stop();
}
}

This was a very simple resolution...

1.) WiFi Shield needed a firmware upgrade to 1.1.0
2.) The shield's antenna is weak so I had to get a better signal

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM