使用“DefaultRequestDirector”和“DefualtHttpCLient”类时Android,Eclipse“找不到源”

I'm trying to create a Login/Register application that uses PHP,MySQL and SQLite to allow users to register via Android as the client. I have my PHP files on my local Apache server. One thing I have run into is an "Access Denied" message when trying to view the "index.php" file on the server. I believe the below config is correct to access my database:

<?php

/**
 * Database config variables
 */
define("DB_HOST", "localhost");
define("DB_USER", "droid");
define("DB_PASSWORD", "");
define("DB_DATABASE", "droidservice");
?>

Does receiving the "Access Denied" message mean my configuration to MySQL database is incorrect?

When I debug the Android application I continue to receive errors saying:

  • "The source attachment does not contain the source for the file DefaultRequestDirector.class"
  • "The source attachment does not contain the source for the file DefaultHttpClient.class"

I'm using a "httpPost" method to access the server and from there parse the JSON. Could the above errors be due to not having the correct http library connected, or some Eclipse config issues?

I've been using the methods primarily from the following tutorial: http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/

1个回答



我在谈论本教程:
http://www.androidhive.info/2012/01/android-login-and-registration-with-php -mysql-and-sqlite / </ p>

您已正确完成数据库设置。 在本教程中,如果未将正确的参数传递给 index.php </ code>文件,将显示“ Access Denied </ code>”。</ p>

如果 您在登录时需要正确观察用户名,密码参数,您需要传递一个名为 tag =“login”</ code>的参数。 在php(index.php)的if条件中,检查此标记以检测请求类型。 (登录或注册)</ p>

Android:</ p>

  params.add(new BasicNameValuePair(“tag”,login_tag)); 
< / code> </ pre>

Php:</ p>

  //检查标签类型
if($ tag =='login'){\ n </ code> </ pre>

如果您传递了tag参数,则不会获得“拒绝访问”消息,并且您的应用程序可以正常运行。 </ p>

同时注册时需要传递</ p>

Android:</ p>

  params.add(new  BasicNameValuePair(“tag”,register_tag)); 
</ code> </ pre>
</ div>

展开原文

原文

I am talking regarding this tutorial: http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/

You have done Database setup correctly. In this tutorial "Access Denied" will be shown if you don't pass correct params to index.php file.

If you observe correctly while login along with username, password parameters you need to pass a param called tag = "login" is passed. In php (index.php) in if condition this tag is checked to detect request type. (login or register)

Android:

params.add(new BasicNameValuePair("tag", login_tag));

Php:

// check for tag type
    if ($tag == 'login') {

If you pass the tag parameter you won't get Access Denied message and your application works perfectly.

Also while registration you need to pass

Android:

params.add(new BasicNameValuePair("tag", register_tag));

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐