i'm trying insert data mysql server when run apps. straight away force close. need in coding. have put logcat txt file below. me take went wrong. thanks.
logcat.txt
05-06 04:23:35.294: e/trace(837): error opening trace file: no such file or directory (2) 05-06 04:23:36.744: d/dalvikvm(837): gc_for_alloc freed 59k, 2% free 10795k/11011k, paused 128ms, total 130ms 05-06 04:23:36.824: i/dalvikvm-heap(837): grow heap (frag case) 16.065mb 5760016-byte allocation 05-06 04:23:36.934: d/dalvikvm(837): gc_concurrent freed <1k, 2% free 16420k/16647k, paused 43ms+17ms, total 106ms 05-06 04:23:37.484: d/androidruntime(837): shutting down vm 05-06 04:23:37.484: w/dalvikvm(837): threadid=1: thread exiting uncaught exception (group=0x40a13300) 05-06 04:23:37.504: e/androidruntime(837): fatal exception: main 05-06 04:23:37.504: e/androidruntime(837): java.lang.runtimeexception: unable start activity componentinfo{mp.memberuse/mp.memberuse.loginregister}: java.lang.runtimeexception: content must have listview id attribute 'android.r.id.list' 05-06 04:23:37.504: e/androidruntime(837): @ android.app.activitythread.performlaunchactivity(activitythread.java:2059) 05-06 04:23:37.504: e/androidruntime(837): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2084) 05-06 04:23:37.504: e/androidruntime(837): @ android.app.activitythread.access$600(activitythread.java:130) 05-06 04:23:37.504: e/androidruntime(837): @ android.app.activitythread$h.handlemessage(activitythread.java:1195) 05-06 04:23:37.504: e/androidruntime(837): @ android.os.handler.dispatchmessage(handler.java:99) 05-06 04:23:37.504: e/androidruntime(837): @ android.os.looper.loop(looper.java:137) 05-06 04:23:37.504: e/androidruntime(837): @ android.app.activitythread.main(activitythread.java:4745) 05-06 04:23:37.504: e/androidruntime(837): @ java.lang.reflect.method.invokenative(native method) 05-06 04:23:37.504: e/androidruntime(837): @ java.lang.reflect.method.invoke(method.java:511) 05-06 04:23:37.504: e/androidruntime(837): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:786) 05-06 04:23:37.504: e/androidruntime(837): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:553) 05-06 04:23:37.504: e/androidruntime(837): @ dalvik.system.nativestart.main(native method) 05-06 04:23:37.504: e/androidruntime(837): caused by: java.lang.runtimeexception: content must have listview id attribute 'android.r.id.list' 05-06 04:23:37.504: e/androidruntime(837): @ android.app.listactivity.oncontentchanged(listactivity.java:243) 05-06 04:23:37.504: e/androidruntime(837): @ com.android.internal.policy.impl.phonewindow.setcontentview(phonewindow.java:259) 05-06 04:23:37.504: e/androidruntime(837): @ android.app.activity.setcontentview(activity.java:1867) 05-06 04:23:37.504: e/androidruntime(837): @ mp.memberuse.loginregister.oncreate(loginregister.java:46) 05-06 04:23:37.504: e/androidruntime(837): @ android.app.activity.performcreate(activity.java:5008) 05-06 04:23:37.504: e/androidruntime(837): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1079) 05-06 04:23:37.504: e/androidruntime(837): @ android.app.activitythread.performlaunchactivity(activitythread.java:2023) 05-06 04:23:37.504: e/androidruntime(837): ... 11 more 05-06 04:23:40.334: i/process(837): sending signal. pid: 837 sig: 9
loginregister.java
package mp.memberuse; import java.io.bufferedreader; import java.io.inputstream; import java.io.inputstreamreader; import java.util.arraylist; import org.apache.http.httpentity; import org.apache.http.httpresponse; import org.apache.http.namevaluepair; import org.apache.http.client.httpclient; import org.apache.http.client.entity.urlencodedformentity; import org.apache.http.client.methods.httpget; import org.apache.http.client.methods.httppost; import org.apache.http.impl.client.defaulthttpclient; import org.apache.http.message.basichttpresponse; import org.apache.http.message.basicnamevaluepair; import android.app.activity; import android.app.listactivity; import android.content.context; import android.content.intent; import android.content.sharedpreferences; import android.content.sharedpreferences.editor; import android.database.cursor; import android.database.sqlite.sqlitedatabase; import android.os.bundle; import android.provider.settings.namevaluetable; import android.util.log; import android.view.view; import android.widget.button; import android.widget.edittext; import android.widget.tabhost; import android.widget.tabhost.tabspec; import android.widget.textview; public class loginregister extends listactivity { button btn1, btn2, btn3; edittext tf1, tf2, tf3, tf4, tf5, tf6, tf7, tf8, tf9, tf10, tf11; textview tv1, tv2; sqlitedatabase db; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); tabhost tabs = (tabhost) this.findviewbyid(r.id.lt2tabhost); tabs.setup(); tabspec ts1 = tabs.newtabspec("login"); ts1.setindicator("login"); ts1.setcontent(r.id.c1); tabs.addtab(ts1); tabspec ts2 = tabs.newtabspec("register"); ts2.setindicator("register"); ts2.setcontent(r.id.c2); tabs.addtab(ts2); btn1 = (button)findviewbyid(r.id.button1); btn2 = (button)findviewbyid(r.id.button2); btn3 = (button)findviewbyid(r.id.button3); tf1=(edittext) findviewbyid(r.id.edittext1); tf2=(edittext) findviewbyid(r.id.edittext2); tf3=(edittext) findviewbyid(r.id.edittext3); tf4=(edittext) findviewbyid(r.id.edittext4); tf5=(edittext) findviewbyid(r.id.edittext5); tf6=(edittext) findviewbyid(r.id.edittext6); tf7=(edittext) findviewbyid(r.id.edittext7); tf8=(edittext) findviewbyid(r.id.edittext8); tf9=(edittext) findviewbyid(r.id.edittext9); tf10=(edittext) findviewbyid(r.id.edittext10); tv1=(textview) findviewbyid(r.id.login); tv2=(textview) findviewbyid(r.id.register); btn1.setonclicklistener(new view.onclicklistener(){ public void onclick(view v) { string username, password; username = tf1.gettext().tostring(); password = tf2.gettext().tostring(); /**try { string sql="select * members;"; cursor c1= db.rawquery(sql, new string[]{}); string sqlusername, sqlpassword, fullname; while(c1.movetonext()) { sqlusername = c1.getstring(0); sqlpassword = c1.getstring(1); fullname = c1.getstring(2); if(username.equals(sqlusername) && password.equals(sqlpassword)) { sharedpreferences prefs = getsharedpreferences("mypreferences",context.mode_private); sharedpreferences.editor editor = prefs.edit(); editor.putstring("fullname", fullname); editor.commit(); intent intent = new intent(loginregister.this, sendmessage.class); startactivity(intent); } else { tv1.settext("invalid user"); } } } catch(exception e) { }**/ } }); btn2.setonclicklistener(new view.onclicklistener(){ public void onclick(view v) { string username, password, cpassword, fullname, nric, address, phone, email; username = tf3.gettext().tostring(); password = tf4.gettext().tostring(); cpassword = tf5.gettext().tostring(); fullname = tf6.gettext().tostring(); nric = tf7.gettext().tostring(); address = tf8.gettext().tostring(); phone = tf9.gettext().tostring(); email = tf10.gettext().tostring(); if(!password.equals(cpassword)) { tv2.settext("password & confirm password not match."); } else if(username.equals("") || password.equals("") || cpassword.equals("") || fullname.equals("") || nric.equals("") || address.equals("") || phone.equals("") || email.equals("")) { tv2.settext("do not leave field empty."); } else { inputstream = null; arraylist<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(); namevaluepairs.add(new basicnamevaluepair("username",username)); namevaluepairs.add(new basicnamevaluepair("password",password)); namevaluepairs.add(new basicnamevaluepair("fullname",fullname)); namevaluepairs.add(new basicnamevaluepair("nric",nric)); namevaluepairs.add(new basicnamevaluepair("address",address)); namevaluepairs.add(new basicnamevaluepair("phone",phone)); namevaluepairs.add(new basicnamevaluepair("email",email)); try { httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost("http://localhost:81/connections.php"); httppost.setentity(new urlencodedformentity(namevaluepairs)); httpresponse response = httpclient.execute(httppost); httpentity entity = response.getentity(); = entity.getcontent(); } catch(exception e) { log.e("log_tag", "error in http connection"+e.tostring()); } tv2.settext("register complete."); tf3.settext(""); tf4.settext(""); tf5.settext(""); tf6.settext(""); tf7.settext(""); tf8.settext(""); tf9.settext(""); tf10.settext(""); } } }); btn3.setonclicklistener(new view.onclicklistener(){ public void onclick(view v) { tf3.settext(""); tf4.settext(""); tf5.settext(""); tf6.settext(""); tf7.settext(""); tf8.settext(""); tf9.settext(""); tf10.settext(""); } }); } }
php code
<?php $hostname_localhost ="localhost"; $database_localhost ="members"; $username_localhost ="root"; $password_localhost =""; mysql_connect($hostname_localhost,$username_localhost,$password_localhost); mysql_select_db("members"); $sql=mysql_query("insert members(username, password, fullname, nric, address, phone, email) values('".$_post['username']."', '".$_post['password']."', '".$_post['fullname']."', '".$_post['nric']."', '".$_post['address']."', '".$_post['phone']."', '".$_post['email']."')"); $r=mysql_query($sql); if(!$r) echo "error in query: ".mysql_error(); mysql_close(); ?>
as in log:
caused by: java.lang.runtimeexception: content must have listview id attribute 'android.r.id.list'
means need declare listview id android:id="@+id/android:list"
in xml layout.
Comments
Post a Comment