Get column information from results of mysql query in php? -


i trying print out column headers query entered. have other code connects database , prints results, having trouble line

'$result .= $heading->name;' 

i keep getting error:

'catchable fatal error: object of class mysqli_result not converted string in...' 

could explain problem is? according php manual should give me right information. new php though, if improve code please explain how did it?

i have following code far gets result query:

$result = mysqli_query($conn,$query); if($result){     if( mysqli_num_rows($result)>0){         $columnno = mysqli_num_fields($result);         for($i=0;$i<$columnno;$i++){             $heading = mysqli_fetch_field_direct($result,$i);             $result .= $heading->name;         }     } } 

$result object being used mysqli. try append string onto end of it.

just use different variable name besides $result string in collect names of columns. or might save names in array this:

$var[] = $heading->name; 

Comments

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

node.js - Why do I get "SOCKS connection failed. Connection not allowed by ruleset" for some .onion sites? -

matlab - 0-by-1 sym - What do I need to change in order to get proper symbolic results? -