arduino connection failed on database

good day! ive been trying to send some data from my arduino to mysql database in my pc. i used nrf24l01 and ethernet module on my arduino and succesfully print my data on the serial monitor. when i tried to connect it to the database, the serial monitor displays connection failure, and now im stuck with it. ill post my code here and please tell me where i had been wrong.

ps. i already ping the arduino from my pc and it is connected.

#include <RF24Network.h>


#include <Ethernet.h>

/*Master TxRx Node 00*/


#include <RF24.h>
#include <SPI.h>



#define soundalarm 1 // for alarm na toh
#define lightalarm 2

int msg[1]; // this is the received data storage

RF24 radio(7, 8);               // nRF24L01 (CE,CSN)
RF24Network network(radio);      // Include the radio in the network

const uint16_t this_node = 00;   // Address of this node in Octal format ( 04,031,etc)
const uint16_t node01 = 01;      // Address of the other node in Octal format

  byte mac[] = {0xDE,0xAD,0xBE,0xEF,0xFE,0xED};
  IPAddress ip(169,254,5,225);
  char server[] = "169.254.5.220";

  EthernetClient client;

void setup() {
  Serial.begin(9600);
  Ethernet.begin(mac,ip);
  SPI.begin();
  radio.begin();
  network.begin(90, this_node);  //(channel, node address)
  radio.setDataRate(RF24_2MBPS);
  
  pinMode(soundalarm, OUTPUT);
  pinMode(lightalarm, OUTPUT);

   
  
  
  pinMode(10,OUTPUT);
 
  digitalWrite(10,HIGH);

  

  
}
void loop() {
  network.update();
  
  //===== Receiving and Sending Ack Signal=====//
  while ( network.available()) {   // Is there any incoming data?
  RF24NetworkHeader header00;
  network.read(header00, &msg[0], sizeof(msg[0])); // Read the incoming data
  Serial.println(msg[0]);

if (msg[0] == 01) {  
    msg[0] = 11; // Read the incoming data and prepares the ack code bits
    digitalWrite(soundalarm, HIGH);
    digitalWrite(lightalarm, HIGH);
    delay(2000); //babaguhin pa  ito
    digitalWrite(soundalarm, LOW);
    digitalWrite(lightalarm, LOW);
    RF24NetworkHeader header01(node01);
    bool ok = network.write(header01, &msg[0], sizeof(msg[0]));}

if (msg[0] == 10) { 
    msg[0] = 11; // Read the incoming data and prepares the ack code bits
    digitalWrite(soundalarm, HIGH);
    digitalWrite(lightalarm, HIGH);
    delay(2000); //babaguhin pa  ito
    digitalWrite(soundalarm, LOW);
    digitalWrite(lightalarm, LOW);
    RF24NetworkHeader header01(node01);
    bool ok = network.write(header01, &msg[0], sizeof(msg[0]));}
    
    // Connect to the server (your computer or web page)  

   msg[1] == msg[0];
  if (client.connect(server, 80)) {
    client.print("GET ,/write_data.php?"); // This
    client.print("&value="); // This
    client.print(msg[1]); // And this is what we did in the testing section above. We are making a GET request just like we would from our browser but now with live data from the sensor
    client.println("HTTP/1.1"); // Part of the GET request
    client.println("Host: 169.254.5.220"); // IMPORTANT: If you are using XAMPP you will have to find out the IP address of your computer and put it here (it is explained in previous article). If you have a web page, enter its address (ie.Host: "www.yourwebpage.com")
    client.println("Connection: close"); // Part of the GET request telling the server that we are over transmitting the message
    client.println(); // Empty line
    client.println(); // Empty line
    client.stop();    // Closing connection to server

  }

  else {
    // If Arduino can't connect to the server (your computer or web page)
    Serial.println("--> connection failed\n");
  }
  delay(10000);
}
     }
int msg[1]; // this is the received data storage

A one element array is pointless.

   msg[1] == msg[0];

Comparing memory you don't own to memory you do own, without caring about whether the comparison is true or false is completely pointless.

Do NOT change that to an equal sign, because crapping on memory you don't own is even worse.

    client.print("GET ,/write_data.php?"); // This

What operating system is on the server, that allows for commas in folder names?

    client.print("&value="); // This

After the ? come name equal value pairs, separated by &s. You have NO name equal value pair between the ? and the first &.

    client.print(msg[1]); // And this is what we did in the testing section

You just tried to send data outside of your array to the server. Completely stupid thing to do.

Put the Arduino away until you can make a PC perform the same actions you are trying to make the Arduino perform. What you are trying to do now is like typing:
http://169.254.5.220:80/,/write_data.php?&value=CompleteCrap
in the address bar of your browser and expecting that to work.

When you CAN type something in the address bar, and the proper data is stored in the database, THEN you can think about getting the Arduino back out.

PaulS:
When you CAN type something in the address bar, and the proper data is stored in the database, THEN you can think about getting the Arduino back out.

Many newbies want to run the marathon before they can even run a block much less a mile.
Terribly misguided.

.

ieee488:
Many newbies want to run the marathon before they can even run a block much less a mile.
Terribly misguided.

.

Or even tie their shoes.

There is nothing wrong with being ambitious, if you are willing to learn and struggle.

PaulS:
Or even tie their shoes.

:slight_smile:

I like this !!!

PaulS:
There is nothing wrong with being ambitious, if you are willing to learn and struggle.

One can tell they don't even understand the very basics.

Even more pathetic is that they want someone else to hand them the answer.

.