In response to the note below me for the claim that mysqli_fetch_fields is not compatible with prepared statements.
This is untrue, it is but you have to do a little extra work. I would recommend you use a wrapper function of some sort to take care of the dirty business for you but the basic idea is the same.
Let's assume you have a prepared statement like so. I am going to use the procedural way for simplicity but the same idea can be done using the object oriented way:
<?php
$connectionLink = mysqli_connect( .... );
$query = "Select `Id` From `Table` Where `Id` = ?";
$prepareObject = mysqli_prepare( $connectionLink , $query );
mysqli_stmt_bind_param( $prepareObject , 'i' , 1 );
mysqli_stmt_execute( $prepareObject );
?>
Now all the above is fine and dandy to anyone familiar with using prepared statements, but if I want to use mysqli_fetch_fields or any other function that fetches meta information about a result set but does not work on prepared statements?
Enter the special function mysqli_stmt_result_metadata. It can be used as follows, assume the following code segment immediatley follows that of the above code segment.
<?php
$metaData = mysqli_stmt_result_metadata( $prepareObject );
$fieldInfo = mysqli_fetch_fields( $metaData );
$fieldInfo = mysqli_num_fields( $metaData );
?>
Take a look at the Manual entry for mysqli_stmt_result_metatdata function for full details on how to expose it with prepared statements.
Good Luck,