public static void executeMultipartPost(String url, String id, String field1, String field2){ try { HttpClient client = new DefaultHttpClient(); HttpPost poster = new HttpPost(url); MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); entity.addPart("name", new StringBody(field1)); entity.addPart("id", new StringBody(id)); entity.addPart("text", new StringBody(field2)); poster.setEntity(entity ); client.execute(poster, new ResponseHandler<Object>() { public Object handleResponse(HttpResponse response) throws ClientProtocolException, IOException { HttpEntity respEntity = response.getEntity(); String responseString = EntityUtils.toString(respEntity); // do something with the response string return null; } }); } catch (Exception e){ //do something with the error } } This is my function for adding a comment.
the problem is that it does not add
my php file
<?php try{ $handler = new PDO('mysql:host=***;dbname=***', '***', '***' ); $handler->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); }catch(Exception $e){ echo $e->getMessage(); die(); } $name = $_POST["name"]; $page_id = $_POST["id"]; $text_comment = $_POST["text"]; $equery = $handler -> query("INSERT INTO `Commnets` (`name`, `page_id`, `text_comment`) VALUES ('$name', '$page_id', '$text_comment')"); $records = array(); I think the problem is in php
can you write me right?
file_put_contents('test.log',var_export($_POST,true))in php and check if the post comes up with a request. - Naumov