Pages: 1 [2]   Go Down
Author Topic: Arduino Ethernet send to php  (Read 1244 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I suggest you stop mucking about with string formatting that you evidently don't understand yet, and just type the URL into your sketch:

Code:
char *pageAdd = "/controlpanel/getalarm.php?alarmstate=0";


Or whatever values you want to use for testing. You can confirm that the path is correct by typing the corresponding URL into the address field of your browser.
Quote

Does the browser show the response you expected? The Arduino should receive the same response, if the network access is succeeding.


Yes in this way i get the right response....How can i i change 0 with the value?
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11176
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes in this way i get the right response....How can i i change 0 with the value?

That's great news. Now we know the only problem is the format of the request string.

Your code to generate it using sprintf was along the right lines. You would need something like this:

Code:
char pageAdd[64];
int alarmstate=0;
sprintf(pageAdd, "/controlpanel/getalarm.php?alarmstate=%d", alarmstate);

That should produce the same behaviour as before. If it doesn't, print the value of pageAdd before you make the page request, and compare it carefully with the fixed string that you know works correctly.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This works correctly but what %d define? I ask because i want to understand how it works so i can send to the web and other values...
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 115
Posts: 5380
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is a list of things sprintf does and how to use them. The float stuff doesn't work last time I checked.
http://www.cplusplus.com/reference/cstdio/printf/
Logged

Pages: 1 [2]   Go Up
Jump to: