How to get data from php

i have index.php to get data from database,
i want thought the php get data to arduino
how can i do?

Download.ino (1.84 KB)

index.txt (343 Bytes)

Post small code directly in line using code tags... can’t read it on mobile

Basically you want to call the URL representing your PHP script and parse the result. If it returns simple values, just a simple parsing might be good enough, if it’s more dynamic returning a JSON structure and analyzing that structure might end up being more flexible.



include 'ConnectDB.php';



/* fetch associative array */    
while ($row = MYSQLI_FETCH_ASSOC($RESULT)) {

echo $x=$_GET[$row["STATUS"]];

echo "STATUS=" . $row["STATUS"] . "



Arduino : This will get all data include html and header and body, i need the post or get data only.

#include "SPI.h"
#include "Ethernet.h"

const int temperaturePin = A0;
byte mac[] = { 0x90, 0xA2, 0xDB, 0x0F, 0x3A, 0xDF };
byte ip[] = { 192, 168, 0, 230 };   //this is the ip address for Ethernet Shield
byte gateway[] = { 192, 168, 0, 254 };
byte subnet[] = { 255, 255, 255, 0 };
EthernetClient client;
char server[] = "";
String mod="",STATUS,rcv;
int interrupt=0;

void setup() {
 // Open serial communications and wait for port to open:

 while (!Serial) {
       ; // wait for serial port to connect. Needed for Leonardo only
 // start the Ethernet connection:
 if (Ethernet.begin(mac) == 0) {
     Serial.println("Failed to configure Ethernet using DHCP");
     // no point in carrying on, so do nothing forevermore:
     // try to congifure using IP address instead of DHCP:
     Ethernet.begin(mac, ip);
 // give the Ethernet shield a second to initialize:

void loop(){

char Result [10];
if (client.connect(server, 80))
     Serial.println("Connection Established");
     client.println("GET /index.php");
     client.println(" HTTP/1.1");        
     client.println("Connection: close"); 

     //Read the server response line by line..     
             String line = client.readStringUntil('\r'); 

     Serial.println("Connection failed");


There are 2 posts pinned at the top of the forum titled:

How to use this forum - please read.
Read this before posting a programming question ...

suggest you start there...

sorry, i edit my post.

so what do you see in the Serial console?

             String line = client.readStringUntil('\r');

If you ever connect, and successfully execute the GET request, this code will print the server response (what the PHP script told it to echo).

If you don't see any output, then your GET request was not successful.