This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Undefined index

 
Gil Carvalho
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I working in a small project and i'm having an error Undefined index;



In line 34 and 35



What's wrong please?

Thank you
 
Roel De Nijs
Sheriff
Posts: 10216
129
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does this work?
 
Gil Carvalho
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

No...

Now i have this in my logCat

02-20 14:43:43.704: E/Buffer Error(22965): Error converting result java.lang.NullPointerException: lock == null

Can't get what is wrong..

And this is my log from Android



 
Roel De Nijs
Sheriff
Posts: 10216
129
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you should first explain what you are trying to do... instead of posting some chuncks of code and let us guess about the purpose of the code
 
Gil Carvalho
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

This is a login system for android.
It uses php, json e android.

Now the undefined index is resolved but i have other issues and i don't know why.

My php is this one after correcting the undefined index





And the error


The Json parse doesn't work....
 
Roel De Nijs
Sheriff
Posts: 10216
129
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But which json is invalid? I assume the var_dump of the user.
 
Gil Carvalho
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No

var_dump($user); prints the following data:



so the query works, the problem is here, response variable seem to be empty...because i don't receive any data in android app



so what i'm doing wrong?

Thank you
 
Roel De Nijs
Sheriff
Posts: 10216
129
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Based on the exception message Value array(6) of type java.lang.String cannot be converted to JSONObject, it seems to be about the var_dump of user, that's an array of 6 elements (and not a json object)
 
Gil Carvalho
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The var_dump was just to check the values, if i remove it i get this error in android app




org.json.JSONException: No value for user

So....i'm lost

 
Roel De Nijs
Sheriff
Posts: 10216
129
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And how does the json-object looks like that you are returning?
 
Gil Carvalho
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Json should return

 
Roel De Nijs
Sheriff
Posts: 10216
129
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gil Carvalho wrote:Json should return

Does your php code returns this json?
 
Gil Carvalho
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No

Returns

{"tag":"login",
"success":1,
"error":0

}
 
Roel De Nijs
Sheriff
Posts: 10216
129
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That explains your error, because there is no user in the json-string and you try to retrieve the "user" key as a JSONObject.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic