php - Updating row in database from android app -



php - Updating row in database from android app -

i'm trying update row in database via android app. pulling database working i'm having problem updating. code updating follows:

my asynctask class:

private class updateanimaltask extends asynctask<void, void, boolean> { @override protected boolean doinbackground(void... arg0) { seek { id = (edittext) findviewbyid(r.id.etid); name = (edittext) findviewbyid(r.id.etname); type = (edittext) findviewbyid(r.id.ettype); breed = (edittext) findviewbyid(r.id.etbreed); gender = (edittext) findviewbyid(r.id.etgender); injuries = (edittext) findviewbyid(r.id.etinjuries); treat = (edittext) findviewbyid(r.id.ettreat); string nm = name.gettext().tostring(); string tp = type.gettext().tostring(); string br = breed.gettext().tostring(); string ge = gender.gettext().tostring(); string in = injuries.gettext().tostring(); string tr = treat.gettext().tostring(); arraylist<namevaluepair> = new arraylist<namevaluepair>(); up.add(new basicnamevaluepair("name", nm)); up.add(new basicnamevaluepair("type", tp)); up.add(new basicnamevaluepair("breed", br)); up.add(new basicnamevaluepair("gender", ge)); up.add(new basicnamevaluepair("injuries", in)); up.add(new basicnamevaluepair("treatment", tr)); string phplink = "http://select.garethprice.co.za/update.php?name=" + nm; log.e("test", up.tostring()); dbupdate(up, phplink); log.e("test", up.tostring()); } catch(exception e) { log.e("log_tag", "error in uploading " + e.tostring()); toast.maketext(getbasecontext(), "error " + e.tostring(), toast.length_long).show(); homecoming false; } homecoming true; } @override protected void onpostexecute(boolean result) { if(result) { toast.maketext(getbasecontext(), "successfully updated", toast.length_long).show(); } } }

my dbupdate method beingness called within asynctask class:

public void dbupdate(arraylist<namevaluepair> data, string phpl) { inputstream = null; seek { defaulthttpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost(phpl); httppost.setentity(new urlencodedformentity(data)); httpresponse response = httpclient.execute(httppost); httpentity entity = response.getentity(); = entity.getcontent(); } catch(exception e) { log.e("log_tag", "error in http connection " + e.tostring()); toast.maketext(getbasecontext(), "error " + e.tostring(), toast.length_long).show(); } }

my php:

<?php include_once 'db.php'; $con=mysql_connect(db_host, db_user, db_password)or die("cannot connect"); mysql_select_db(db_database)or die("cannot select db"); $nm = $_get['name']; $tp = $_post['type']; $br = $_post['breed']; $ge = $_post['gender']; $in = $_post['injuries']; $tr = $_post['treatment']; $sql = "update tbl_animals set animal_type = '$tp', animal_breed = '$br', animal_gender = '$ge', animal_injuries = '$in', animal_treatments = '$tr' animal_name = '$nm'"; echo "test: " . $nm . $tp . $br . $ge . $in . $tr; mysql_query($sql,$con) or die("error: " . mysql_error()); mysql_close($con) ?>

executing asynctask in update button:

public void update(view v) { new updateanimaltask().execute(); }

the android code not breaking suspect it's php because toast pops says update successful in onpostexecute. give thanks in advance.

php android mysql android-asynctask sql-update

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -