Data type conversion for GET posts

I am trying to gather sensor info from various devices, and compile it into a char and have it posted to a server via php and the HTTP GET method.

When i compile this code i get "invalid operands of types 'const char*' and 'const char [6]' to binary 'operator+'"

#include "arduino4G.h"
// APN settings
///////////////////////////////////////
char apn[] = "";
char login[] = "";
char password[] = "";
///////////////////////////////////////

// SERVER settings
///////////////////////////////////////
char host[] = "";
uint16_t port = 80;
char resource[] = "";
///////////////////////////////////////

// variables
uint8_t error;
int Hum;
int pH;
int lat;
int lon;
int temp;


void setup()
{
  error = _4G.ON();
  Serial.println(F("Start program"));
  
  //********************************************************************
  // GET method to the Libelium's test url                              
  // You can use this php to test the HTTP connection of the module.    
  // The php returns the parameters the user sends with the URL.        
  //********************************************************************

  //////////////////////////////////////////////////
  // 1. sets operator parameters
  //////////////////////////////////////////////////
  _4G.set_APN(apn, login, password);

  //////////////////////////////////////////////////
  // 2. Show APN settings via USB port
  //////////////////////////////////////////////////
  _4G.show_APN();
}


void loop()
{
  //////////////////////////////////////////////////
  // 1. Switch ON
  //////////////////////////////////////////////////  
  error = _4G.ON();

  if (error == 0)
  {
    Serial.println(F("1. 4G module ready..."));

    ////////////////////////////////////////////////
    // 2. HTTP GET
    ////////////////////////////////////////////////
    Serial.println(F("2. Getting URL with GET method..."));

    // send the request
    error = _4G.http( GET_METHOD, host, port, resource);

resource = "&Temp=" + temp
                          + "&Hum=" + Hum + "&lvl=" + lon //fix
                          + "&pH=" + "Enter sensor here" + "&lat=" +  "&long=";


}

BUT, when I make the following changes below, I get this message.

#include "arduino4G.h"
// APN settings
///////////////////////////////////////
char apn[] = "";
char login[] = "";
char password[] = "";
///////////////////////////////////////

// SERVER settings
///////////////////////////////////////
char host[] = "";
uint16_t port = 80;
String resource;

///////////////////////////////////////

// variables
uint8_t error;
String Hum;
String pH;
String lat;
String lon;
String temp;


void setup()
{
  error = _4G.ON();
  Serial.println(F("Start program"));
  
  //********************************************************************
  // GET method to the Libelium's test url                              
  // You can use this php to test the HTTP connection of the module.    
  // The php returns the parameters the user sends with the URL.        
  //********************************************************************

  //////////////////////////////////////////////////
  // 1. sets operator parameters
  //////////////////////////////////////////////////
  _4G.set_APN(apn, login, password);

  //////////////////////////////////////////////////
  // 2. Show APN settings via USB port
  //////////////////////////////////////////////////
  _4G.show_APN();
}


void loop()
{
  //////////////////////////////////////////////////
  // 1. Switch ON
  //////////////////////////////////////////////////  
  error = _4G.ON();

  if (error == 0)
  {
    Serial.println(F("1. 4G module ready..."));

    ////////////////////////////////////////////////
    // 2. HTTP GET
    ////////////////////////////////////////////////
    Serial.println(F("2. Getting URL with GET method..."));

    // send the request
    error = _4G.http( GET_METHOD, host, port, (String resource));

resource = "&Temp=" + (temp)
                          + "&Hum=" + (Hum) + "&lvl=" + (lon) //fix
                          + "&pH=" + "Enter sensor here" + "&lat=" +  "&long=";

This error that highlights the line ** error = _4G.http( GET_METHOD, host, port, (String resource));**

expected primary-expression before 'resource'

resource, is normally a char based on the sample code provided with the 4G module as shown in the first segment of code.

I can't find the library arduino4G.h that you're using : can you provide a link?

In your first code, the error tells you that you can't concatenate char arrays using '+', like this:

resource = "&Temp=" + temp
                          + "&Hum=" + Hum + "&lvl=" + lon //fix
                          + "&pH=" + "Enter sensor here" + "&lat=" +  "&long=";

In all cases, resource should be defined before calling _4G.http

If the _4G.http requires a char array, you can use a String and transform it to a char :

String Sresource = "&Temp=" + temp
                          + "&Hum=" + Hum + "&lvl=" + lon //fix
                          + "&pH=" + "Enter sensor here" + "&lat=" +  "&long=";
resource = Sresource.toCharArray();

and then call

error = _4G.http( GET_METHOD, host, port, resource);

lesept:
I can't find the library arduino4G.h that you're using : can you provide a link?

In your first code, the error tells you that you can't concatenate char arrays using '+', like this:

resource = "&Temp=" + temp

+ "&Hum=" + Hum + "&lvl=" + lon //fix
                          + "&pH=" + "Enter sensor here" + "&lat=" +  "&long=";



In all cases, resource should be defined *before* calling _4G.http

If the _4G.http requires a char array, you can use a String and [transform it to a char](https://www.arduino.cc/reference/en/language/variables/data-types/string/functions/tochararray/) :


String Sresource = "&Temp=" + temp
                          + "&Hum=" + Hum + "&lvl=" + lon //fix
                          + "&pH=" + "Enter sensor here" + "&lat=" +  "&long=";
resource = Sresource.toCharArray();


and then call


error = _4G.http( GET_METHOD, host, port, resource);

Helpful info, thank you.

I do indeed still get the "invalid operands of types 'const char*' and 'const char [6]' to binary 'operator+'" error

String Sresource = "&Temp=" + temp
                          + "&Hum=" + Hum + "&lvl=" + lon //fix
                          + "&pH=" + "Enter sensor here" + "&lat=" +  "&long=";
resource = Sresource.toCharArray();
 // send the request
    error = _4G.http( GET_METHOD, host, port, resource);

Here is the link to the library. If you scroll to 3.8.1 you can see the section on HTTP requests.
https://www.cooking-hacks.com/documentation/tutorials/4g-gps-lte-wcdma-hspa-3g-gprs-shield-arduino-raspberry-pi-waspmote-tutorial/#step3

Maybe the problem comes from GET_METHOD which does not seem to be initialized. The link you provide says

The http() function configures HTTP parameters, performs the request selected by the user and handles data received from server.

This function needs several parameters to work properly depending on the method used. The first parameter required by the function is the request method. User can choose amongst five methods: GET, HEAD, DELETE, POST and PUT:

Wasp4G::HTTP_GET
Wasp4G::HTTP_HEAD
Wasp4G::HTTP_DELETE
Wasp4G::HTTP_POST
Wasp4G::HTTP_PUT
After choosing the method, the function needs the host URL, port and resource of the HTTP server requested. The data field is only necessary when POST or PUT methods are performed.
_4G.http(Wasp4G::HTTP_GET, host, port, resource);

So you should add in the beginning of your code file (before the setup)
#define GET_METHOD Wasp4G::HTTP_GETor directly

error = _4G.http( Wasp4G::HTTP_GET, host, port, resource);

Looking at the library, it says the arguments for http are :

uint8_t http( uint8_t method,
char* url,
uint16_t port,
char* resource);

So we need to find a way to create that char array. Lets try this:

char*[80] resource
sprintf (resource, "&Temp=%d&Hum=%d&lvl=%d&pH=Enter sensor here&lat=&long=\0",temp,Hum,lon);

This assumes that temp, hum and l'on are int variables.
If you keep them as String, then it's a little bit more complex. You must change all %d to %s and change temp to temp.c_str(),and the same for the others.
You can read more about sprintf here