How to send GPS coordinate to a database

Hello, I am a newbie in arduino.

I am using Arduino NodeMcu ESP8266 and a Arduino GY-NEO6MV2 GPS module to receive the coordinate,

but I do not know how to send it into database(PHPMyadmin).

Can anyone help me?

Thank you in Advance :slight_smile: .

I try using this code

#include <SoftwareSerial.h>
#include <ESP8266WiFi.h>
#include <TinyGPS.h>
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>

TinyGPS gps;
SoftwareSerial ss(4,3);

IPAddress server_addr(127,x,x,x); //This is okay

char user[]="root";
char password[]="";

char INSERT_SQL[] = "INSERT INTO evento.lonlat(longitude, latitude) VALUES (flon,flat)";

char ssid[] = "Myssid";
char pass[] = "Mypassword";

WiFiClient client;
MySQL_Connection conn(&client);
MySQL_Cursor* cursor;

void setup()
{
  Serial.begin(9600);
  ss.begin(9600);

//  Serial.println("Connecting to %s", ssid);
  WiFi.begin(ssid,pass);
  while (WiFi.status() !=WL_CONNECTED){
    delay(500);
    Serial.print(".");
  }
  
  Serial.print("Simple TinyGPS library v. "); Serial.println(TinyGPS::library_version());
  Serial.println("by Mikal Hart");
  Serial.println();
  Serial.println("\nConnected to network");
  Serial.print("My IP address is: ");
  Serial.println(WiFi.localIP());

  Serial.print("Connecting to SQL...  ");
  if (conn.connect(server_addr, 80, user, password))
    Serial.println("OK.");
  else
    Serial.println("FAILED.");
  
  // create MySQL cursor object
  cursor = new MySQL_Cursor(&conn);
}

void loop()
{
  bool newData = false;
  unsigned long chars;
  unsigned short sentences, failed;

  // For one second we parse GPS data and report some key values
  for (unsigned long start = millis(); millis() - start < 1000;)
  {
    while (ss.available())
    {
      char c = ss.read();
       //Serial.write(c); // uncomment this line if you want to see the GPS data flowing
      if (gps.encode(c)) // Did a new valid sentence come in?
        newData = true;
    }
  }

  if (newData)
  {
    float flat, flon;
    unsigned long age;
    gps.f_get_position(&flat, &flon, &age);
    Serial.print("LAT=");
    Serial.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
    Serial.print(" LON=");
    Serial.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
    Serial.print(" SAT=");
    Serial.print(gps.satellites() == TinyGPS::GPS_INVALID_SATELLITES ? 0 : gps.satellites());
    Serial.print(" PREC=");
    Serial.print(gps.hdop() == TinyGPS::GPS_INVALID_HDOP ? 0 : gps.hdop());
    
  }
  
  gps.stats(&chars, &sentences, &failed);
  Serial.print(" CHARS=");
  Serial.print(chars);
  Serial.print(" SENTENCES=");
  Serial.print(sentences);
  Serial.print(" CSUM ERR=");
  Serial.println(failed);
  if (chars == 0){
    Serial.println("** No characters received from GPS: check wiring **");
  }
    if (conn.connected())
    cursor->execute(INSERT_SQL);

  delay(5000); 
}

but it gave this error
"Connecting to SQL... FAILED.
ERROR: Class requires connected server."