REsource is like a file handle, or a pointer to a resource. Tyring to access or print out the resource itself simply returns the resource number.
Say you want to query a database:
$query = "SELECT some,stuff FROM table WHERE criteria='true'";
$result = mysql_result($query);
$result is a resource (a multidimensional array, in fact):
resource = (
1 => array(
some => 'foo',
stuff => 'bar'),
1 => array(
some => 'foo2',
stuff => 'bar2'),
etc....)
But the array is only pointed to by its resource id, and so you can't print it directly.
You'd retrieve values from it via a call such as:
//mysql_fetch_assoc retrieves each subarray, representing a row, as an associative 1-dimensional array
while($row = mysql_fetch_assoc($result)){
echo "some equals " . $row['some'] . "<br />";
echo "stuff equals " . $row['stuff'] . "<br />";
}
(prints out:
some equals foo
stuff equals bar
some equals foo2
stuff equals bar2
and so on)
Does that help?
Dan
|