-1

I am creating a home weather station but the Arduino IDE shows

"expected ';' before 'viewport'". 

It detects wrong quotation marks. My code:

     String message2 = "<!DOCTYPE html>";
  message2 += "<head>";
  message2 +=  "<title>Bootstrap Example</title>";
  message2 += " <meta name="viewport" content="width=device-width, initial-scale=1">";
  message2 += "<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">";
  message2 +=  "<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>";
  message2 +=  "<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>";
  message2 += "</head>";
  message2 += "<body>";
  message2 += "<div class="container">";
  message2 +=  "<h2>Teplotná Stanica</h2>";
  message2 +=  "<p>Teplota:";
  message2 +=  dht.readTemperature();
  message2 +=  "</p>";

  server.send(200, "text/html", message2);}

Can someone tell me what´s wrong? I am using Arduino IDE

3
  • 1
    Have you looked at your quotes yet? All of them? Nov 12, 2017 at 15:04
  • I wonder who upvoted this question.
    – user31481
    Nov 13, 2017 at 15:14
  • Your question has been answered. Please, accept the answer to close this question.
    – user31481
    Nov 17, 2017 at 9:31

1 Answer 1

7

In C you can not use quotation marks inside quotation marks (thus nested).

Replace

message2 += " <meta name="viewport" content="width=device-width, initial-scale=1">";

to

message2 += " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">";

By using the escape character \ it means that \" is a character (") instead of the beginning or start of a string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.