Send data of LM35DZ to database SQL and MQTT broker at the same time

When I run the code the serial monitor shows the value of the temperature but then it does not send to the MQTT broker nor to the database if it runs the code in separad, that is, one at a time it already sends or to the database or to the MQTT broker, how can I send both sides at the same time?

#include <ESP8266WiFi.h>
#include <Ethernet.h>
#include <PubSubClient.h>
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>

const char * ssid = "xxxxxxxxx"; // network ssid wifi
const char * password = "xxxxxxxxxxxx"; // wifi password network
const char * mqttServer = "xxx.xxx.xxx.xxx"; // IP address of Raspberry Pi
const int mqttPort = 1883; // Port by default of MQTT
const char * mqttUser = "test"; // MQTT Username, if the authentication in the broker is configured
const char * mqttPassword = "test"; // MQTT Password, if the authentication in the broker is configured

float tempC // Define tempC variable by converting it to float data type.
int reading; // Define reading variable by converting it to the int data type.
float referenceVoltage; // Defines referenceVoltage variable by converting it to the float data type.
int tempPin = A0; // Analog pin where it is connected or LM35
String convert; // Initialize the convert variable as String
char array [6]; // Initialization of the char array with 6 positions
WiFiClient spClient // Create the object
PubSubClient client (espClient) // Instantiate the MQTT client by passing the espClient object

IPAddress server_addr (xxx, xxx, xxx, xxx); // IP of the MySQL * server * here
char login_username [] = "xxxxx"; // MySQL user login username
char login_password [] = "xxxx"; // MySQL user login password
//// Sample query
char INSERT_SQL [] = "INSERT INTO MQTT.TESTES (Temperature) VALUES (% .3f)";
char query [255];
MySQL_Connection conn (& espClient);
MySQL_Cursor * cursor;

void setup () {
Serial.begin (115200);

/ * Connection to the Wi-Fi network * /
referenceVoltage = 1; // Reference voltage of ESP82666
/ * Connection to the Wi-Fi network * /
Serial.printf ("\ nConnecting to% s", ssid);
WiFi.begin (ssid, password);
while (WiFi.status ()! = WL_CONNECTED) {
delay (500);
Serial.print (".");
}
/ * Connection to MQTT * /
client.setServer (mqttServer, mqttPort);
while (! client.connected ()) {
Serial.println ("Connecting to MQTT ...");
if (client.connect ("ESP8266Client", mqttUser, mqttPassword)) {
Serial.println ("connected to the MQTT");
} else {
Serial.print ("failed with state");
Serial.print (client.state ());
delay (5000);
}
}

// print out info about the connection:
Serial.println ("\ nConnected to network");
Serial.print ("My IP address is:");
Serial.println (WiFi.localIP ());
/ * Connection to the SQL database * /
Serial.println ("Connecting to SQL ...");
if (conn.connect (server_addr, 3306, login_username, login_password))
Serial.println ("OK.");
else
Serial.println ("FAILED.");
// create the MySQL object cursor
cursor = new MySQL_Cursor (& conn);
}
void loop () {

reading = 0;
for (int i = 0; i <10; i ++) {// Average of 10 readings to make the reading more accurate
reading + = analogRead (tempPin);
//Serial.println(reading);// Shows the values ​​of the 10 readings
delay (20); // A0 pin reading time every 20 milliseconds
}
// Conversion of analog voltage to temperature value in degrees Celsius and to an array
tempC = (referenceVoltage * reading * 10) / 1023;
convert + = tempC; // Converts the value of the variable tempC to string
convert.toCharArray (array, 6) // convert the string into a char array with 6 positions

//Data to the MQTT Broker
client.publish ("esp8266", array);
Serial.println (array);
convert = "";
client.loop ();
delay (2000);

//Data to the SQL Database

Serial.print (query);
if (conn.connected ())
sprintf (query, INSERT_SQL, tempC);
cursor-> execute (query);
delay (2000);
}

The result when i run the code is the serial.println(array), but not publish in MQTT broker, was i show in the image:

Capturar333.PNG