如何使用php服务器将mysql数据库连接到android表单?

时间:2014-11-28 10:07:21

标签: php android mysql json

我正在尝试使用mysql数据库和php服务器端编码在android(eclipse ide)中为电话簿功能进行表单设计。

我怀疑create.php文件夹中xampp/htdocs文件的位置。我创建了一个自定义文件夹并放置了.php文件。 ?

http连接部分的MainActivity.java文件中提到的IP地址是什么?

我已经通过互联网答案完成了所有可能的操作,但是在Android表单中点击提交按钮没有来自avd的响应。

我的错误日志低于

  11-28 15:26:47.012: E/WindowManager(865): android.view.WindowLeaked: Activity       com.example.phonebook.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{1112109d V.E..... R.....ID 0,0-229,175} that was originally added here
  11-28 15:26:47.012: E/WindowManager(865):     at android.view.ViewRootImpl.<init>(ViewRootImpl.java:363)
  11-28 15:26:47.012: E/WindowManager(865):     at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:261)
  11-28 15:26:47.012: E/WindowManager(865):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
  11-28 15:26:47.012: E/WindowManager(865):     at android.app.Dialog.show(Dialog.java:298)
  11-28 15:26:47.012: E/WindowManager(865):     at com.example.phonebook.MainActivity$loginAccess.onPreExecute(MainActivity.java:111)
  11-28 15:26:47.012: E/WindowManager(865):     at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:587)
  11-28 15:26:47.012: E/WindowManager(865):     at android.os.AsyncTask.execute(AsyncTask.java:535)
  11-28 15:26:47.012: E/WindowManager(865):     at com.example.phonebook.MainActivity$2.onClick(MainActivity.java:84)
  11-28 15:26:47.012: E/WindowManager(865):     at android.view.View.performClick(View.java:4756)
  11-28 15:26:47.012: E/WindowManager(865):     at android.view.View$PerformClick.run(View.java:19749)
  11-28 15:26:47.012: E/WindowManager(865):     at android.os.Handler.handleCallback(Handler.java:739)
  11-28 15:26:47.012: E/WindowManager(865):     at android.os.Handler.dispatchMessage(Handler.java:95)
  11-28 15:26:47.012: E/WindowManager(865):     at android.os.Looper.loop(Looper.java:135)
  11-28 15:26:47.012: E/WindowManager(865):     at android.app.ActivityThread.main(ActivityThread.java:5221)
  11-28 15:26:47.012: E/WindowManager(865):     at java.lang.reflect.Method.invoke(Native Method)
  11-28 15:26:47.012: E/WindowManager(865):     at java.lang.reflect.Method.invoke(Method.java:372)
  11-28 15:26:47.012: E/WindowManager(865):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
  11-28 15:26:47.012: E/WindowManager(865):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

 httpclient=new DefaultHttpClient();
        httppost= new HttpPost("http://127.0.0.1:8080/crm/check.php"); // make sure the url is correct.

我尝试更改httppost连接的网址。但结果是服务器没有响应。

2 个答案:

答案 0 :(得分:1)

此崩溃是由于在http连接期间显示的对话框没有传递正确的上下文或问题与对话框有关,因为如果您粘贴代码我可以帮忙

答案 1 :(得分:0)

http连接部分的MainActivity.java文件中提到的IP地址是什么?

Ans:如果您正在使用linux,请执行ifconfg命令,您将获得ipaddress ex :: 192.168.1.101。这将是您的本地主机,您可以使用此链接提供php文件的链接。 例如:http://192.168.1.101/API/check.php其中连接写在check.php