您好,欢迎访问一九零五行业门户网

android虚拟机在xampp的集成环境下,向mysql插入id,name数据

虚拟机xampp数据androidmysql
客户端界面如下:
info1.php代码
android客户端代码
public class mainactivity extends activity {
edittext id;
edittext name;
button ok;
inputstream is = null;
private static string url = http://192.168.56.1/php/info1.php;@overrideprotected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); id = (edittext)findviewbyid(r.id.id); name = (edittext)findviewbyid(r.id.name); ok = (button)findviewbyid(r.id.ok); ok.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { // todo 自动生成的方法存fajfa log.v(break, 进入try过程); try { string text1 = id.gettext().tostring(); string text2 = name.gettext().tostring(); arraylist para = new arraylist(); para.add(new basicnamevaluepair(id, text1)); para.add(new basicnamevaluepair(name, text2)); httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost(url); httppost.setentity(new urlencodedformentity(para)); httpclient.execute(httppost); }catch(exception e) { e.printstacktrace(); } } });}
}
我尝试把httppost的参数改为很多方式。。
比如 private static string url = http://localhost/php/info1.php;
private static string url = http://127.0.0.1/php/info1.php;
private static string url = http://10.0.2.15/php/info1.php;
都不能把数据给插入成功。。
我不知道是url 设置错了。还是其他哪里错了。如果您知道,请大家告诉小弟一下。




其它类似信息

推荐信息