Wednesday, 15 May 2013

http - Send long Variable to a PHP file in Android -



http - Send long Variable to a PHP file in Android -

i have function in android app sends long string php file inserts database. now, problem is, php file never whole string application.

is possible string shortened if send http parameter? or have thought whats possible wrong?

(i'm sorry bad english, i'm not native speaker)

my java code:

httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost("http://********/********/map/addmarkers.php"); arraylist<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(); seek { namevaluepairs.add(new basicnamevaluepair("marker", functions.objtostring(spm[i].getmarkertosave()+""))); namevaluepairs.add(new basicnamevaluepair("database",database[spm[i].gettype()])); httppost.setentity(new urlencodedformentity(namevaluepairs)); httpresponse response = httpclient.execute(httppost); log.d("marker als string ",functions.objtostring(spm[i].getmarkertosave())+""); log.d("database",database[spm[i].gettype()]); bufferedreader in = new bufferedreader(new inputstreamreader(response.getentity().getcontent())); string line = ""; while ((line = in.readline()) != null) { log.d("antwort des servers: ",line); } in.close(); } grab (exception e) { e.printstacktrace(); }

my php code:

<?php $db = @new mysqli('xxxxxxx', 'dbxxxxx', 'xxxx', 'dbxxxxx'); if (mysqli_connect_errno()) { die('konnte keine verbindung zur datenbank aufbauen: '.mysqli_connect_error().'('.mysqli_connect_errno().')'); } $marker_tostring = $_post["marker"]; $db_name= $_post["database"]; $sql = "insert $db_name (marker_tostring) values ('$marker_tostring')"; echo "marker: $marker_tostring"; echo "db: $db_name"; $eintragen = mysqli_query($db, $sql);

?>

antwort des servers:

logfile:

marker als string r000acxnyac9jb20uxweansmsdfpiwenfefnwiwnfepwnfpn.......

database park_markers

antwort des servers: marker: ro0abxqaclnryxrllvnob3a= db: ****

you url encoding name value pairs. have url decode them on php side.

android http

No comments:

Post a Comment