Can't get MKR1010 WIFI to add data to MySQL database.

Hi all,

I’m trying to get my MKR1010 WiFi to add sensor data to a MySQL database but it doesn’t seem to be working.

thingProperties.h code

#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>
#include <WiFi.h>

const char THING_ID[] = "c942a18f-7696-4431-952c-76eaea3214ea";

const char SSID[]     = SECRET_SSID;    // Network SSID (name)
const char PASS[]     = SECRET_PASS;    // Network password (use for WPA, or use as key for WEP)
const char server[] = SECRET_IP;

void onRainChange();

int airPressure;
float lightIntensity;
float relativeHumidity;
bool rain;
float temperature;

void initProperties(){

  ArduinoCloud.addProperty(airPressure, READ, 60 * SECONDS, NULL);
  ArduinoCloud.addProperty(lightIntensity, READ, ON_CHANGE, NULL);
  ArduinoCloud.addProperty(relativeHumidity, READ, 60 * SECONDS, NULL);
  ArduinoCloud.addProperty(rain, READWRITE, 60 * SECONDS, onRainChange);
  ArduinoCloud.addProperty(temperature, READ, 60 * SECONDS, NULL);


WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);

Main code:

#include "thingProperties.h"
#include <Arduino_MKRENV.h>
#include <WiFi.h>
#define WATER_SENSOR 2

WiFiClient client;
int status = WL_IDLE_STATUS;

void setup() {
  // Initialize serial and wait for port to open:
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  // attempt to connect to Wifi network:
  while (status != WL_CONNECTED) {
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(SSID, PASS);
    // wait 10 seconds for connection:
  // Defined in thingProperties.h

  // Connect to Arduino IoT Cloud
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
  if (!ENV.begin()) {
  Serial.println("Failed to initialize MKR ENV shield!");
  /*WiFi setup*/

void loop() {
 // Your code here 
 relativeHumidity = int(ENV.readHumidity());
 lightIntensity = (ENV.readIlluminance());
 airPressure = int(ENV.readPressure(MILLIBAR));
 temperature = int(ENV.readTemperature());
 if(digitalRead(WATER_SENSOR) == LOW){
   rain = 1;
 }else if(digitalRead(WATER_SENSOR) == HIGH){
   rain = 0;
  // if there's a successful connection:
  if (client.connect(server, 80)) {
    // send the HTTP PUT request:
    client.print("GET /weather_data.php?");
    client.print(" HTTP/1.1");
    client.println("Host: ");
    client.println("Connection: close");

void onRainChange() {
  // Do something