Hello everyone,
I don't know is 'storage' the best section for my topic.
I have simple problem:
I had wrote simple php page which inserts data from POST to database.
I know, that my script is working, because I tested it on http://www.requestmaker.com/ I can send data to save into database. Program to send data on arduino does not work properly. I think, i forgot something...
I know, that POST request fires, because in database i have new records, but they are empty - instead of POST messages sended by http://www.requestmaker.com/
I'm using ENC 28J60 and arduino uno (but i think, that is does not matter)
Can anyone help?
Arduino code:
#include <EtherCard.h>
#define PATH "temp.php"
byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
char website[] PROGMEM = "www.iskrzycki.hekko.pl";
byte Ethernet::buffer[700];
uint32_t timer;
Stash stash;
void setup () {
Serial.begin(57600);
Serial.println("\n[webClient]");
if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
Serial.println( "Failed to access Ethernet controller");
if (!ether.dhcpSetup())
Serial.println("DHCP failed");
if (!ether.dnsLookup(website))
Serial.println("DNS failed");
ether.printIp("SRV: ", ether.hisip);
}
void loop () {
ether.packetLoop(ether.packetReceive());
if (millis() > timer) {
timer = millis() + 10000;
byte sd = stash.create();
stash.print("t0=22");
stash.save();
Stash::prepare(PSTR("POST http://www.iskrzycki.hekko.pl/temp.php HTTP/1.0" "\r\n"
"Host: www.iskrzycki.hekko.pl \r\n"
"Content-Length: $D" "\r\n"
"\r\n"
"$H"),
stash.size(), sd);
ether.tcpSend();
}
}
PHP CODE:
<html>
<body>
<?php
$link = mysql_connect("HOST", "LOGIN", "PASS") or die("Keine Verbindung möglich: " . mysql_error());
mysql_select_db("DATABASE") or die("Auswahl der Datenbank fehlgeschlagen");
$query = "INSERT INTO table1(temp, data) VALUES ('" . $_POST['t0'] . "', now())";$result = mysql_query($query) or die("Anfrage fehlgeschlagen: " . mysql_error());
mysql_close($link);
?>
</body>
</html>
post.ino (1.08 KB)
phpInsert.php (418 Bytes)