Results 1 to 3 of 3
  1. #1

    Unhappy Androdid communication with mysql php login script

    Dear Sirs and Madams!

    I am trying to login into mysql database on some server from my Galaxy Note mobile device (Android 2.2.6). Now, once i execute post in following code:
    Code:
    private void loginToDatabase(final String strUsername,
                                       final String strPassword)
        {
                HttpClient client=new DefaultHttpClient();
                HttpPost post=new HttpPost("myserver/php/login.php");
                HttpResponse response=null;
    
            try
            {
                List<NameValuePair> loginInfo=new ArrayList<NameValuePair>(2);
    
                loginInfo.add(new BasicNameValuePair("username",
                                                     strUsername));
                loginInfo.add(new BasicNameValuePair("password",
                                                     strPassword));
    
                post.setEntity(new UrlEncodedFormEntity(loginInfo));
    
                response=client.execute(post);
            }
            catch(Exception e)
            {
                int i=0;
            }
            finally
            {
            }   // try-catch-finally
        }   // loginToDatabase
    and once I watch response variable in debug session, the response object holds "Internal Server Errror (500).". Here is my php script:
    PHP Code:
    <?php
        session_start
    ();

        if(
    $_SERVER["REQUEST_METHOD"] == "POST")
        {
            
    $hostname_localhost ="localhost";
            
    $database_localhost ="database";
            
    $username_localhost ="user";
            
    $password_localhost ="password";
     
            
    $localhost=mysql_connect($hostname_localhost,
                         
    $username_localhost,
                         
    $password_localhost) or die(mysql_error());

            
    #echo "Connected to Server.<br/>";

            
    mysql_select_db($database_localhost) or die(mysql_error());

            
    #echo "Connected to Database.<br/>";

            
    $username=mysql_real_escape_string($_POST['username']);
            
    $password=mysql_real_escape_string($_POST['password']);

            
    $query_user=mysql_query("SELECT id_customer, lastname, firstname FROM ps_customer WHERE email=$username AND passwd=$password";
            
    $number_of_users=mysql_num_rows($query_user);
            if(
    $number_of_users==1)
            {
                echo 
    "User found.<br/>";
            }
            else
            {
                echo 
    "User not found.<br/>;
            }
        }
    ?>
    Why am I getting this error?

  2. #2

    recall a similar solution

    From someone at digitalplayground. With a android login to a MySQL database for file sharing and other.



  3. #3
    I solved it, on demand I can send a code.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •