Go Down

Topic: Arduino ethernet webclient php script and mysql (Read 63715 times) previous topic - next topic

xsilvergs

@ vinhtvu2. Sorry I haven't been back to this post for a while other matters have cropped up. Your work looks very interesting I'll be back soon.

xsilvergs

Hi,

I can get data by sending command http://192.168.1.19/?a=getTemp1 from my web browser but how do you do it by .php?

I've tried this:
Code: [Select]
<html>
The temperature is <?php echo $_GET["http://192.168.1.19/?a=getTemp1"]; ?>
</html>


The webpage then displays:
Code: [Select]
The temperature is


but the temp vale is never displayed.

Has anybody an ideas on the code I require?

Thanks

PaulS

In PHP, $_GET is a variable (an array of name/value pairs, to be exact) that is valued when a GET request of a php script is made. It is not used the way you are trying to.

The way you are trying to use it, the script is trying to find the value that goes with the name "http://192.168.1.19/?a=getTemp1", which is clearly not a valued name.

In the GET request, "http://192.168.1.19/?a=getTemp1", the name of the script to execute is supposed to go between the kast slash and the question mark. If the script is a php script, the $_GET variable will be populated with the names in front of the equal signs, using the values that follow the equal signs. In your case, you would be able to get the value getTemp1 that goes with the name a.

Clearly, there is some issue with what you are trying to do. The Arduino appears to be functioning as a server, so what php has to do with the output from the Arduino is not clear.

Go Up