I have some php code that processes a get request which is waiting for an application to post some url to it. Here is my url waiting for the post: http://www.myurl.com/msgid=&msg_content=100+08151000091+1111&msg_sender=2347062698846 here is my php code.
$msgid = (int)htmlentities(strip_tags($_GET['msgid']));
$msg_content = htmlentities(strip_tags($_GET['msg_content']));
$msg_sender = htmlentities(strip_tags($_GET['msg_sender']));
$con = mysqli_connect('hostname', 'database', 'password');
if (!$con) {
die('Could not connect: ' . mysql_error());
}
//echo 'Connected successfully';
mysqli_select_db($con,msg);
mysqli_query($con,"INSERT INTO messages (ID, Content, sender)
VALUES ('$msgid', '$msg_content','$msg_sender')");
mysqli_close($con);
Here is the problem. When I post from java code to the above url, I receive the response is:
IOException - Invalid Http response.
But it works when i paste the url directly to a browser. Please where am I am getting it wrong?
The above PHP code does not "return" anything on the output. Thus, your Java snippet is complaining about the empty output to not to be valid HTML with an IO Exception.