Driving me mad.  Integer to text for URL GET/

Hi, I've only been using the Arduino for a few days. I have programmed Mircochip PIC's before, though I'm no expert.

I have come up against a problem and have been banging my head against the wall for a while with it.

I have my Arduino talking to my server via ethernet and can store data in a MySQL database. The problem is, at the moment I can only send the same data over and over, as a static string.

The lines that make up the URL and pass the data are:

plen= es.ES_fill_tcp_data_p(buf,0, PSTR ( "GET /arduino_write.php?pwd=mypassword" ) ); plen= es.ES_fill_tcp_data_p(buf, plen, PSTR ( "&status=123" ));

So the php script on the server checks the password 'pwd' and then inserts the '123' from 'status', into the database. That all works fine, but I need to get data from an analogue pin for the 'status' The analogue data would be of type (int), and it seems I would need to turn that into a char[] array and feed that to the TCP buffer one byte at a time using a loop.

So how would I go about getting say the int 1023 into a char[] array?

I'm not even sure if that's the way to go. Like I said, this is pretty new to me.

If anyone has any ideas, I'd be glad of any help.

Many thanks.

you can try the itoa() function for integers, because you can use C code in your sketches...

http://en.wikipedia.org/wiki/Itoa

example (untested code):

char buffer[5];
itoa(1023,buffer,DEC);

Wow, that was quick.

Dude you’re a jedi :sunglasses:

Had a quick read up on itoa and done the business.

Here’s what I did:

int value;
char data[5];

value=random(1023);
itoa(value, data, 10);

plen= es.ES_fill_tcp_data_p(buf, plen, PSTR ( “&status=” ));
for(i=0; data*!=’\0’; i++){*
buf[TCP_DATA_P+plen]=data*;
_
plen++;_
_
}*_
Just used a random gen to test with, but I now have dynamic data filling my database.
Thanks.