object to resource mysql_query

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cucucur
Forum Newbie
Posts: 7
Joined: Tue Apr 05, 2011 2:01 am

object to resource mysql_query

Post by cucucur »

hi! I have an java object in my php code, and I would like to cast it to a mysql_query resource, how can I do that?

Here is my error:
Warning: mysql_fetch_array() expects parameter 1 to be resource, object given
Thank you in advance!
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: object to resource mysql_query

Post by fugix »

can you show us the mysql_fetch_array code?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: object to resource mysql_query

Post by pickle »

You're missing something. You can't have a Java object in PHP code.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: object to resource mysql_query

Post by fugix »

it might not necessarily be an object. Its most likely an error in the writing of the code and the parse recognizes it as an object when its actually not
cucucur
Forum Newbie
Posts: 7
Joined: Tue Apr 05, 2011 2:01 am

Re: object to resource mysql_query

Post by cucucur »

hi! it's actually a java variable, I'm using php java bridge:

Code: Select all

         $objeto = new Java('pruebaLog');
         $conexion = $objeto -> connectDB();
         $result = $objeto->returnParkingMapData($conexion, 2);
         mysql_fetch_array($result);

returnParkingMapData returns a java object resultSet.

fugy, how can I know if it is an object or what is it?

Thank you so much!
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: object to resource mysql_query

Post by pickle »

Actually returnParkingMapData() would return a PHP object that you use to interact with Java.
Edit: I'm not trying to be a petty know-it-all. I just want to make sure you understand exactly what is going on.

If you want to know the type of variable, you can use gettype(). Perhaps a more useful function would be var_dump(), which dumps a bunch of different information about the variable.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply