Pages: [1]   Go Down
Author Topic: ARDUINO + PHP  (Read 1371 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I m sending two values (heart rate and temperature) database into Apache Server like:

float temperature = 30.8;
float heart = 120;

client.println("get /arduino.php?temp=temperature&hr=heart");

And the values aren't sent. but like this i can but i want to send variable values:

client.println("get /arduino.php?temp=30.8&hr=120");

Help me thanks
Logged

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

For reference, split it between multiple print strings and terminate that sequence with a println.
To answer this question:
Code:
client.print("get /arduino.php?temp="); //print the constant string
client.print(temperature); //print the variable temperature's value, note the lack of quotation marks
client.print("&hr="); //print the constant string
client.println(heart); //finally send the variable heart's value and a newline, in order to submit the data

The OP's problem was that they were sending the request as a constant string, so what the server was getting was "get /arduino.php?temp=temperature&hr=heart"
« Last Edit: June 17, 2013, 05:36:53 am by _hg_ » Logged

Correct me if I'm wrong.

Use common sense when writing code. Some functions work similarly across libraries.

South England
Offline Offline
Full Member
***
Karma: 3
Posts: 205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I know I'm being picky here but shouldn't heart rate be an 8-bit int rather than a float? Resolution of 0.1bpm seems unnecessary and if it goes above 255 an alarm rather than a precise reading ought to suffice  smiley-wink Same goes for values below zero.
Logged

Pages: [1]   Go Up
Jump to: