HTTP Bad Request from Arduino missing separator ':'

Hi guys,

Im getting an error after posting to a web server.

This is my php code:

<?php
$conex = mysql_connect("localhost", "user", "pwd");

if(!$conex){
    die("Couldn't connect to the server...
".mysql_error());
}

$db = mysql_select_db("test", $conex);

if(!$db){
    die("Couldn't connect to the database...
".mysql_error());
}

$Estado_Boton = $_POST["Estado_Boton"];

$sql = "INSERT INTO example (name) VALUES ('$Estado_Boton') ";

$res = mysql_query($sql, $conex);

?>

This is my Request code:

if (wifly.open(site, 80)) {
       Serial.print("Connected to ");
	Serial.println(site);
	
        /* Send the request */
	//wifly.println("GET /query.php HTTP/1.0");
	wifly.println("POST /arduino/data_process.php HTTP/1.0");
	wifly.println("Host: www.santiapps.com"); // SERVER ADDRESS HERE TOO
        wifly.println("Content-Type: text/html; charset=utf-8");
        wifly.println("Content-Length: ");
        wifly.println(data.length());
        wifly.println("Connnection: close");
	wifly.println();
        wifly.print(data);
   } else {
       Serial.println("Failed to connect");
   }

This is the server response:

HTTP Bad Request from Arduino missing separator ‘:’

I’ve looked around the web but all i found is some httpd related posts.

Anybody ever get this?

        wifly.println("Content-Length: ");
       wifly.println(data.length());

You are printing the data length on a separate line from the Content-Length: Shouldn't they be on the same line?

Pete

You mean it should be:

wifly.println("Content-Length: " + data.length());

Im not at desk right now so I can't try it. I just looked up an example and found that one. I just found a different one that doesn't even use Content-Length. So Ill try both options when I get back.

Im also not sure as to the order of the calls. The Connection: close being before the print(data)

Oh, I also just noticed that Content-Length is only using print, without new line. So that may be why its being printed like that.