HTML page not working Wifi Sensor

Hi all!
I have a code at the moment which is measuring different sensors, and sending the results to an app which I have made.
I am doing this by creating a HTML web page with the data on it. However, my data, which sends every 3 seconds, only works 6-7 times before i get a consistent error- that my HTML page is not available.
Wondering if it has something to do with my code? Any suggestions

#define DHTPIN 11
#include "DHT.h"
#define DHTTYPE DHT22
#include <SPI.h> //try??? idk
#include <WiFiNINA.h>

int soilPin = A0;
int tempPin = 11;
int lightPin = A2;

char ssid[] = "iiNet580D53";      // your network SSID (name)
char pass[] = "hY2KfZcCNW";   // your network password
// int keyIndex = 0;                 // your network key Index number (needed only for WEP)

WiFiServer server(80); //declare server object and spedify port, 80 is port used for internet
int status = WL_IDLE_STATUS; //status of wifi


DHT dht(DHTPIN, DHTTYPE);


void setup() {
  Serial.begin(9600);
  dht.begin();
  pinMode(soilPin, INPUT);
  pinMode(tempPin, INPUT);
  // 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);
    Serial.println(WiFi.localIP());
    delay(5000);
  }
  server.begin();

}

void loop() {
  WiFiClient client = server.available();   // listen for incoming clients
  if (client) {                             // if you get a client,
           String currentLine = "";                // make a String to hold incoming data from the client
           while (client.connected()) {            // loop while the client's connected
                if (client.available()) {             // if there's bytes to read from the client,
                    char c = client.read();             // read a byte, then
                    if (c == '\n') {                    // if the byte is a newline character

                          if (currentLine.length() == 0) {
                            
                  client.println("HTTP/1.1 200 OK");
                  client.println("Content-type:text/html");
                  client.println("Connnection: close");
                  client.println();
                  client.println("<!DOCTYPE HTML>");
                  client.println("<html>");
                  client.println("<meta http-equiv=\"refresh\" content=\"5\">");
                  
                          float h = dht.readHumidity();
                          float t = dht.readTemperature();

                          client.print("Humidity: ");
                          client.print(h);
                          client.println(" %\t");
                          client.print("
");
                          client.print("Temperature: "); 
                          client.print(t-4);
                          client.println(" *C ");
                          client.print("
");
                          client.print("Soil Moisture: "); 
                          client.print(analogRead(soilPin));
                          client.print("
");
                          client.print("Light Resistance:  ");
                          client.println(analogRead(lightPin));
                          client.print("Ohms");
                            delay(3000);


                          
                          
                      // client.println("
"); // idk
                      // client.println("</html>"); // idk
                          
                     break;
               }
          else {      // if you got a newline, then clear currentLine:
          currentLine = "";
        }
                    }

     else if (c != '\r') {    // if you got anything else but a carriage return character,
     currentLine += c;      // add it to the end of the currentLine         
         }
                }
           }
  }
  }

Before posting code, do format it properly (the IDE makes it really easy with the autoformat function). Makes it a lot more readable.

rubyhackett3:
6-7 times before i get a consistent error- that my HTML page is not available.

I don't see your code throwing any such error so I may assume it's your server throwing that error, and I suppose that's what you should be looking at.

                          client.print("Light Resistance:  ");
                          client.println(analogRead(lightPin));
                          client.print("Ohms");

The value returned by analogRead() is NOT in Ohms. It is a unit-less value that is the ratio of the measured voltage to the reference voltage, multiplied by 1024.

You should be reading the temperature, humidity, soil moisture and light level independent of any client request. When there is a client request, return the last values obtained from those sensors.

                      // client.println("</html>"); // idk

I have no idea what your cryptic comment means, but you DO need that statement to print that tag.

You REALLY need to learn the wonders of the Tools + Auto Format tool.