MySql database is not being updated
<p>im trying to run my application but I keep getting my else statment "can not log in" and no information is being passed or updating my database..... can someone help me out here and see what the problem is. Thanks in advance</p>

<p>here is my java</p>

<pre><code>package the.review;

 import java.io.InputStream;
 import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;


public class LoginJ extends Activity {
Button login; 
String name="",pass="", EMAIL=""; 
EditText username,password, email; 
TextView tv; 
byte[] data; 
HttpPost httppost; 
StringBuffer buffer; 
HttpResponse response; 
HttpClient httpclient; 
InputStream inputStream; 
SharedPreferences app_preferences ; 
List&lt;NameValuePair&gt; nameValuePairs; 
CheckBox check;
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.login); 
    app_preferences = PreferenceManager.getDefaultSharedPreferences(this); 
    username = (EditText) findViewById(R.id.username); 
    password = (EditText) findViewById(R.id.password);
    email = (EditText) findViewById(R.id.email);
    login = (Button) findViewById(R.id.login); 
    check = (CheckBox) findViewById(R.id.check); 

    String Str_user = app_preferences.getString("username","0" ); 
    String Str_pass = app_preferences.getString("password", "0"); 
    String Str_EMAIL = app_preferences.getString("email", "0");
    String Str_check = app_preferences.getString("checked", "no"); 
    if(Str_check.equals("yes")) {
        username.setText(Str_user); 
        password.setText(Str_pass);
        email.setText(Str_EMAIL);
        check.setChecked(true);

    }
    login.setOnClickListener(new View.OnClickListener()
    {

        public void onClick(View v) {
            name = username.getText().toString(); 
            pass = password.getText().toString();
            EMAIL = email.getText().toString();
            String Str_check2 = app_preferences.getString("checked", "no"); 
            if(Str_check2.equals("yes")) 
            {
                SharedPreferences.Editor editor = app_preferences.edit(); 
                editor.putString("username", name); 
               editor.putString("password", pass); 
               editor.putString("email", EMAIL);
                 editor.commit();

            }



            if(name.trim().equals("") || pass.trim().equals("") || EMAIL.trim().equals(""))
            {
                    Toast.makeText(LoginJ.this, "Blank Field..Please Enter", Toast.LENGTH_LONG).show    ();
            }
            else{

            try{

                 httpclient = new DefaultHttpClient(); 
                                       httppost = new HttpPost  ("http://10.0.2.2/AppConnection/main.php"); 

                                        // Add your data 
                                        nameValuePairs = new ArrayList&lt;NameValuePair&gt;(3); 
                                       nameValuePairs.add(new BasicNameValuePair("UserName", name.trim())); 
                                        nameValuePairs.add(new BasicNameValuePair("Password", pass.trim())); 
                                        nameValuePairs.add(new BasicNameValuePair("email", pass.trim())); 
                                        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); 

                                        // Execute HTTP Post Request 
                                        response = httpclient.execute(httppost); 
                                        inputStream = response.getEntity().getContent(); 


                                        ResponseHandler&lt;String&gt; responseHandler = new BasicResponseHandler();
                                        String response = httpclient.execute(httppost, responseHandler);
                                        System.out.println("Response : " + response);                                           
                                        // check the string from the php side...
                                        if(response.equalsIgnoreCase("Y")){
                                            Toast.makeText(LoginJ.this, "login successfull", Toast.LENGTH_LONG).show(); 
                                        }else{
                                            Toast.makeText(LoginJ.this, "Cannot Log In", Toast.LENGTH_LONG).show(); 
                                        }


                                        data = new byte[256]; 

                                        buffer = new StringBuffer(); 
                                        int len = 0; 
                                        while (-1 != (len = inputStream.read(data)) ) 
                                        { 
                                            buffer.append(new String(data, 0, len)); 
                                        } 
                                        inputStream.close(); 
            } 

            catch (Exception e) 
            {  
                Toast.makeText(LoginJ.this, "error"+e.toString(), Toast.LENGTH_LONG).show(); 
            } 
            if(buffer.charAt(0)=='Y') 
            { 
                Toast.makeText(LoginJ.this, "login successfull", Toast.LENGTH_LONG).show(); 
            } 
            else
            { 
                Toast.makeText(LoginJ.this, "Invalid Username or password", Toast.LENGTH_LONG).show(); 
            } 
            } 
        } 
    }); 
    check.setOnClickListener(new View.OnClickListener() 
    { 
        public void onClick(View v) 
        { 
            // Perform action on clicks, depending on whether it's now checked 
            SharedPreferences.Editor editor = app_preferences.edit(); 
            if (((CheckBox) v).isChecked()) 
            { 

                 editor.putString("checked", "yes"); 
                 editor.commit(); 
            } 
            else
            { 
                 editor.putString("checked", "no"); 
                 editor.commit(); 
            } 
        } 
    }); 
} 
    public void Move_to_next() 
    { 

    startActivity(new Intent(this, TheClassReviewActivity.class)); 
    }   
}
</code></pre>

<p>And here is my PHP</p>

<pre><code>   $hostname_localhost = "localhost";
$database_localhost = "logindatabase";
$username_localhost = "root";

$localhost = mysql_connect($hostname_localhost,$username_localhost)
or
trigger_error(mysql_error(),E_USER_ERROR);


        require_once('Connections/localhost.php'); mysql_select_db($database_localhost,$localhost);
$UserName = $_POST['UserName'];
$Password = $_POST['Password'];
$email = $_POST['email']

mysql_query("INSERT INTO tbl_users (UserName, Password, email) VALUES    ('".$UserName."', '".$Password."', '".$email."')";
$query_exec = mysql_query($query_insert) or die (mysql_error());
$rows = mysql_num_rows($query_exec);

if($rows --&gt; 0) {echo "Y";}
else {echo "N";}
</code></pre>

<p>Thanks again for any help or pointers</p>
