wood burning stoves 2.0*
The moose likes PHP and the fly likes Undefined index Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Languages » PHP
Bookmark "Undefined index" Watch "Undefined index" New topic
Author

Undefined index

Gil Carvalho
Ranch Hand

Joined: Dec 10, 2013
Posts: 57
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
Bartender

Joined: Jul 19, 2004
Posts: 5593
    
  14

Does this work?


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Gil Carvalho
Ranch Hand

Joined: Dec 10, 2013
Posts: 57
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
Bartender

Joined: Jul 19, 2004
Posts: 5593
    
  14

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

Joined: Dec 10, 2013
Posts: 57
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
Bartender

Joined: Jul 19, 2004
Posts: 5593
    
  14

But which json is invalid? I assume the var_dump of the user.
Gil Carvalho
Ranch Hand

Joined: Dec 10, 2013
Posts: 57
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
Bartender

Joined: Jul 19, 2004
Posts: 5593
    
  14

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

Joined: Dec 10, 2013
Posts: 57
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
Bartender

Joined: Jul 19, 2004
Posts: 5593
    
  14

And how does the json-object looks like that you are returning?
Gil Carvalho
Ranch Hand

Joined: Dec 10, 2013
Posts: 57
Json should return

Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5593
    
  14

Gil Carvalho wrote:Json should return

Does your php code returns this json?
Gil Carvalho
Ranch Hand

Joined: Dec 10, 2013
Posts: 57
No

Returns

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

}
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5593
    
  14

That explains your error, because there is no user in the json-string and you try to retrieve the "user" key as a JSONObject.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Undefined index