Value <br of type java.lang.String cannot be converted to JSONObject// php error
<p>I want to access Android apps through Web-Service. In the web service the new registration is performed. In the android apps, the xml file for the new registration is made. The data is saved successfully in SQL server database and it save properly by web service and return data get in jason string.</p>

<p>But when string is converted to JSONObject, it give me error like this:</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>04-23 08:59:15.892 25063-25063/com.example.shy.wel D/RegisterActivity: Login Response: &lt;br /&gt;
                                                                       &lt;b&gt;Fatal error&lt;/b&gt;:  Call to undefined method mysqli_stmt::get_result() in &lt;b&gt;/home/u395192838/public_html/include/DB_Functions.php&lt;/b&gt; on line &lt;b&gt;64&lt;/b&gt;&lt;br /&gt;
04-23 08:59:15.917 25063-25090/com.example.shy.wel E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7fdb7c637da0
04-23 08:59:15.951 25063-25063/com.example.shy.wel W/System.err: org.json.JSONException: Value &lt;br of type java.lang.String cannot be converted to JSONObject</code></pre>
</div>
</div>
</p>

<p>I don't know why that.. <strong><em>DB_Funtuion.php</em></strong> on line 64 is not working</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>                $user = $stmt-&gt;get_result()-&gt;fetch_assoc();</code></pre>
</div>
</div>
</p>

<p>My all <strong><em>DB_Funtuion.php</em></strong> this</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;?php
 
/**
 * @author Ravi Tamada
 * @link http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/ Complete tutorial
 */
 
class DB_Functions {
 
    private $conn;
 
    // constructor
    function __construct() {
        require_once 'DB_Connect.php';
        // connecting to database
        $db = new Db_Connect();
        $this-&gt;conn = $db-&gt;connect();
    }
 
    // destructor
    function __destruct() {
         
    }
 
    /**
     * Storing new user
     * returns user details
     */
    public function storeUser($name, $email, $password) {
        $uuid = uniqid('', true);
        $hash = $this-&gt;hashSSHA($password);
        $encrypted_password = $hash["encrypted"]; // encrypted password
        $salt = $hash["salt"]; // salt
 
        $stmt = $this-&gt;conn-&gt;prepare("INSERT INTO users(unique_id, name, email, encrypted_password, salt, created_at) VALUES(?, ?, ?, ?, ?, NOW())");
        $stmt-&gt;bind_param("sssss", $uuid, $name, $email, $encrypted_password, $salt);
        $result = $stmt-&gt;execute();
        $stmt-&gt;close();
 
        // check for successful store
        if ($result) {
            $stmt = $this-&gt;conn-&gt;prepare("SELECT * FROM users WHERE email = ?");
            $stmt-&gt;bind_param("s", $email);
            $stmt-&gt;execute();
            $user = $stmt-&gt;get_result()-&gt;fetch_assoc();
            $stmt-&gt;close();
 
            return $user;
        } else {
            return false;
        }
    }
 
    /**
     * Get user by email and password
     */
    public function getUserByEmailAndPassword($email, $password) {
 
        $stmt = $this-&gt;conn-&gt;prepare("SELECT * FROM users WHERE email = ?");
 
        $stmt-&gt;bind_param("s", $email);
 
        if ($stmt-&gt;execute()) {
            $user = $stmt-&gt;get_result()-&gt;fetch_assoc();
            $stmt-&gt;close();
 
            // verifying user password
            $salt = $user['salt'];
            $encrypted_password = $user['encrypted_password'];
            $hash = $this-&gt;checkhashSSHA($salt, $password);
            // check for password equality
            if ($encrypted_password == $hash) {
                // user authentication details are correct
                return $user;
            }
        } else {
            return NULL;
        }
    }
 
    /**
     * Check user is existed or not
     */
    public function isUserExisted($email) {
        $stmt = $this-&gt;conn-&gt;prepare("SELECT email from users WHERE email = ?");
 
        $stmt-&gt;bind_param("s", $email);
 
        $stmt-&gt;execute();
 
        $stmt-&gt;store_result();
 
        if ($stmt-&gt;num_rows &gt; 0) {
            // user existed 
            $stmt-&gt;close();
            return true;
        } else {
            // user not existed
            $stmt-&gt;close();
            return false;
        }
    }
 
    /**
     * Encrypting password
     * @param password
     * returns salt and encrypted password
     */
    public function hashSSHA($password) {
 
        $salt = sha1(rand());
        $salt = substr($salt, 0, 10);
        $encrypted = base64_encode(sha1($password . $salt, true) . $salt);
        $hash = array("salt" =&gt; $salt, "encrypted" =&gt; $encrypted);
        return $hash;
    }
 
    /**
     * Decrypting password
     * @param salt, password
     * returns hash string
     */
    public function checkhashSSHA($salt, $password) {
 
        $hash = base64_encode(sha1($password . $salt, true) . $salt);
 
        return $hash;
    }
 
}
 
?&gt;</code></pre>
</div>
</div>
</p>

<p>And my <strong><em>LoginActivity</em></strong> java </p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>package com.example.shy.wel.activity;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.android.volley.Request.Method;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.example.shy.wel.LoadingActivity;
import com.example.shy.wel.MainActivity;
import com.example.shy.wel.R;
import com.example.shy.wel.app.AppConfig;
import com.example.shy.wel.app.AppController;
import com.example.shy.wel.helper.SQLiteHandler;
import com.example.shy.wel.helper.SessionManager;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

public class LoginActivity extends Activity {
    private static final String TAG = RegisterActivity.class.getSimpleName();
    private Button btnLogin;
    private Button btnLinkToRegister;
    private EditText inputEmail;
    private EditText inputPassword;
    private ProgressDialog pDialog;
    private SessionManager session;
    private SQLiteHandler db;






    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);

        Intent loading = new Intent(this, LoadingActivity.class);
        startActivity(loading);

        inputEmail = (EditText) findViewById(R.id.email);
        inputPassword = (EditText) findViewById(R.id.password);
        btnLogin = (Button) findViewById(R.id.btnLogin);
        btnLinkToRegister = (Button) findViewById(R.id.btnLinkToRegisterScreen);

        // Progress dialog
        pDialog = new ProgressDialog(this);
        pDialog.setCancelable(false);

        // SQLite database handler
        db = new SQLiteHandler(getApplicationContext());

        // Session manager
        session = new SessionManager(getApplicationContext());

        // Check if user is already logged in or not
        if (session.isLoggedIn()) {
            // User is already logged in. Take him to main activity
            Intent intent = new Intent(LoginActivity.this, MainActivity.class);
            startActivity(intent);
            finish();
        }

        // Login button Click Event
        btnLogin.setOnClickListener(new View.OnClickListener() {

            public void onClick(View view) {
                String email = inputEmail.getText().toString().trim();
                String password = inputPassword.getText().toString().trim();

                // Check for empty data in the form
                if (!email.isEmpty() &amp;&amp; !password.isEmpty()) {
                    // login user
                    checkLogin(email, password);
                } else {
                    // Prompt user to enter credentials
                    Toast.makeText(getApplicationContext(),
                            "Please enter the credentials!", Toast.LENGTH_LONG)
                            .show();
                }
            }

        });

        // Link to Register Screen
        btnLinkToRegister.setOnClickListener(new View.OnClickListener() {

            public void onClick(View view) {
                Intent i = new Intent(getApplicationContext(),
                        RegisterActivity.class);
                startActivity(i);
                finish();
            }
        });

    }

    /**
     * function to verify login details in mysql db
     * */
    private void checkLogin(final String email, final String password) {
        // Tag used to cancel the request
        String tag_string_req = "req_login";

        pDialog.setMessage("Logging in ...");
        showDialog();

        StringRequest strReq = new StringRequest(Method.POST,
                AppConfig.URL_LOGIN, new Response.Listener&lt;String&gt;() {


            @Override
            public void onResponse(String response) {
                Log.d(TAG, "Login Response: " + response.toString());
                hideDialog();


                try {
                    JSONObject jObj = new JSONObject(response);
                    boolean error = jObj.getBoolean("error");

                    // Check for error node in json
                    if (!error) {
                        // user successfully logged in
                        // Create login session
                        session.setLogin(true);

                        // Now store the user in SQLite
                        String uid = jObj.getString("uid");

                        JSONObject user = jObj.getJSONObject("user");
                        String name = user.getString("name");
                        String email = user.getString("email");
                        String created_at = user.getString("created_at");

                        // Inserting row in users table
                        db.addUser(name, email, uid, created_at);

                        // Launch main activity
                        Intent intent = new Intent(LoginActivity.this,
                                MainActivity.class);
                        startActivity(intent);
                        finish();
                    } else {
                        // Error in login. Get the error message
                        String errorMsg = jObj.getString("error_msg");
                        Toast.makeText(getApplicationContext(),
                                errorMsg, Toast.LENGTH_LONG).show();
                    }
                } catch (JSONException e) {
                    // JSON error
                    e.printStackTrace();
                    Toast.makeText(getApplicationContext(), "Json error: " + e.getMessage(), Toast.LENGTH_LONG).show();
                }

            }
        }, new Response.ErrorListener() {

            @Override
            public void onErrorResponse(VolleyError error) {
                Log.e(TAG, "Login Error: " + error.getMessage());
                Toast.makeText(getApplicationContext(),
                        error.getMessage(), Toast.LENGTH_LONG).show();
                hideDialog();
            }
        }) {

            @Override
            protected Map&lt;String, String&gt; getParams() {
                // Posting parameters to login url
                Map&lt;String, String&gt; params = new HashMap&lt;String, String&gt;();
                params.put("email", email);
                params.put("password", password);

                return params;
            }

        };

        // Adding request to request queue
        AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
    }

    private void showDialog() {
        if (!pDialog.isShowing())
            pDialog.show();
    }

    private void hideDialog() {
        if (pDialog.isShowing())
            pDialog.dismiss();
    }
}</code></pre>
</div>
</div>
</p>