You are invited to Log in or Register a free Frihost Account!

Need help understanding MySQL "Resource" type retu

I'm trying to work with data returned from mySQL db. I've done some tutorials and have checked out and the like, and I still don't understand this, and was hoping someone could help. Maybe explain it, or show me someplace that can.
When certain types of quries (fetch array, etc.) are performed, the function returns is a resource... so if you echo it back, it says resource id#3 or something.
What does this mean? and how do you work with that? How is it useful?
The other functions I'm aware of (fetch field, fetch object etc) return a field as an object. And, unfortunately, I don't totally understand the ins and outs of this either. How is working with a returned object different... do I have to make the object and then pull the value from the db?
I'm sure this is all really obvious, but something just isn't clicking for me, and I need help.
the resource id, REALLY SIMPLY AND BASICALLY EXPLAINED, is just a number that points to that connection symbol -remember, there's no REAL connection like in strings attached and stuff, it's mainly software-based, and it gets really complicated to explain correctly-. It was formerly used as a parameter you could put into a variable and punch into another function, i.e. mysql_fetch_row or mysql_real_escape_string.

As for the object you are talking about, it's an array, except for the mysql_fetch_object and mysql_fetch_field, which I never ever in my life used. Arrays can be represented as a grid with at least 2 dimensions -even if you specify only one, which I might explain later on-: The position of the value and the value itself. Imagine this type of thing.

Array of fruits:


This is stored quite like this on the machine's memory:
***1º fruit: banana*****
***2º fruit: orange*****
***3ºfruit: lemon******

an array can have as many dimensions you want. A dimension can b e thought as a 'category' , and are represented like this: $fruits['red']['sweet']['whateverOtherCategory']['whateverElse']='apple';

This is just a 5' primer on arrays, I recommend you get the php manual in chm format, it's really handy if you want to know more about the language itself.
Related topics
Dreamweaver Help!
Help Installing MySQL on SuSE Linux using ssh
Help with mysql query
Phpbb and PhpNuke Help
need help with mysql joins
Need Help with mysql database of DragonflyCMS
pls help about mysql errorr
200 frih for a flash animation
Need help with mySQL
Finding the newest entry in a mysql database?
mySQL help needed, any other good database thing?
Beer Brewing
DDR1/2 RAM, anyone can help?
What MySQL Data type would you use to store a Webpage
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

© 2005-2011 Frihost, forums powered by phpBB.