Ethercard + Arduino posting data is blank in db


hi,

i'm using enc28j60 arduino , using ethercard library. when url parse data browser data gets mysql db. arduino post blank. below sketch , please me resolve this.
code: [select]


#include <ethercard.h>

// variable

string key = "a123ds";
string sid = "ps1"

// ethernet interface mac address, must unique on lan
byte mymac[] = { 0x74,0x69,0x69,0x2d,0x30,0x31 };

const char website[] progmem = "192.168.1.106";

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, 4) == 0)
    serial.println( "failed access ethernet controller");
  if (!ether.dhcpsetup())
    serial.println("dhcp failed");

  ether.printip("ip:  ", ether.myip);
  ether.printip("gw:  ", ether.gwip); 
  ether.printip("dns: ", ether.dnsip); 
#if 0
  if (!ether.dnslookup(website))
    serial.println("dns failed");
#else
  ether.parseip(ether.hisip, "192.168.1.106");
#endif
  ether.printip("srv: ", ether.hisip);
}

void loop () {
  ether.packetloop(ether.packetreceive());

  if (millis() > timer) {
    timer = millis() + 5000;

    byte sd = stash.create();
    stash.print("apikey=");
    stash.print(key);
    stash.print("station_id=");
    stash.print(sid);
    stash.save();

    stash::prepare(pstr("post http://192.168.1.106/savecontactinfo.php?sd http/1.0" "\r\n"
                "host: 192.168.1.106 \r\n"
                "content-length: $d" "\r\n"
                "content-type: application/x-www-form-urlencoded \r\n"
                "\r\n"
                "$h"),
    stash.size(), sd);// website, pstr(path), website,

    // send packet - releases stash buffers once done
    ether.tcpsend();

  }
}





when try send data maybe problem stash or when sending stash
code: [select]

 stash::prepare(pstr("post http://192.168.1.106/savecontactinfo.php?apikey=a123ds&station_id=ps1 http/1.0" "\r\n"
                "host: 192.168.1.106 \r\n"
                "content-length: $d" "\r\n"
                "content-type: application/x-www-form-urlencoded \r\n"
                "\r\n"
                "$h"),
    stash.size(), sd);// website, pstr(path), website,

    // send packet - releases stash buffers once done
    ether.tcpsend();



so please tell me doing wrong. need urgent guys
thanks advance

- have tried ensure reachability form arduino network? sure works?

- web server use? sure it's reachable outside hosting machine?

- see in logs of web server?

as side note, don't think matters but

- have space @ end of
"host: 192.168.1.106 \r\n" before \r\n --> rid of it

- size last element before empty line, move "content-type: application/x-www-form-urlencoded \r\n"before "content-length: $d" "\r\n"



Arduino Forum > Using Arduino > Programming Questions > Ethercard + Arduino posting data is blank in db


arduino

Comments

Popular posts from this blog

Help with codes to add 1 more shift register and add more to matrix LED

tcp client

Is there an HTML component in Flex 2.0?