org.json.JSONException: Value br of type java.lang.String cannot be converted to JSONObject
Thanks I manage to correct some of the errors 2 ';' were missing and I could see the error with Log.i("tagconvertstr", "["+result+"]");
The msg that it is showing is something like that :
[<br/ > font size = 1 table class=''xdebug-erroe' dir='ltr' ... loads of html code that wasn't in my initial code then....{"message":"Problem sending you the activation mail !"}]
So there's a problem with the json format on that message "Problem sending you the activation mail" but the user was registered OK!
So the second time i would try that code it would show me in a correct json format : "This email has already been used" ! (without any errors) but i still can't find the error in my php code : S
org.json.JSONException: Value Connected of type java.lang.String cannot be converted to JSONObject
When instantiating a JSONObject you need to pass the actual string response:
ex: JSONObject obj = new JSONObject("result":[{"unique_id":"57933c641237d4.96974874","title":"23072016"},{"unique_id":"57901472464398.57585757","title":"hayley"}]");
Given that response.toString()
gives you the string you should do the following:
JSONObject j = new JSONObject(response.toString());
P.S: I think you need this if you don't set the content type in your php :
<?
header('Content-Type: application/json');
$servername = "localhost";
$username = "USER";
$password = "PASS";
$dbname ="android_api";
....
Register Error: org.json.JSONException: Value br of type java.lang.String cannot be converted to JSONObject
You most likely got broken PHP code, line
echo_json_encode($result);
should rather look like that:
echo json_encode($result);
Related Topics
How to Bind SQL Variables in PHP
Highlight Keywords in a Paragraph
Applied Coupons Disable Free Shipping Conditionally in Woocommerce
Convert Number to Letter with PHP
How to Pass Variables from JavaScript to PHP
Sum Specific Values in a Multidimensional Array (Php)
How to Solve Error 404 When Deploying Laravel Project to Cpanel
Errorbag Is Always Empty in Laravel 5.2
PHP Password_Verify() Hash and Pass Won't Match
Unknown Modifier '/' in ...? What Is It
Display Custom Order Meta Data Value in Email Notifications Woocommerce
How to Escape Single-Quote (Apostrophe) in String Using PHP
Why Is PHP Not Replacing the Variable in String
Proper Repository Pattern Design in PHP