Why does this work:
$query "SELECT * FROM TABLE";
$result = mysql_query($query,$dbc) or die(mysql_error()) ;
// Print first column of query result
do {
echo "<br>";
echo $row_result[mysql_field_name($result, 0)];
}
while ($row_result = mysql_fetch_assoc($result));
And this doesn't:
function print_result($result)
{
do {
echo "<br>";
echo $row_result[mysql_field_name($result, 0)];
}
while ($row_result = mysql_fetch_assoc($result));
}
$query "SELECT * FROM TABLE";
$query_result = mysql_query($query,$dbc) or die(mysql_error()) ;
print_result($query_result);
I've been able to get some MySQL functions to work on the passed query result or resource but others like this do not seem to work. Like echo-ing the $result will show the same resource id inside and outside of the function. I've been able to get the field names via mysql_field_name but printing out the query in the form of a table gives me empty results.