venturemc Posted September 4, 2009 Share Posted September 4, 2009 Having trouble extracting the values form the mysqli_fetch_fields command. ...... $fldinfo = $result->fetch_fields(); foreach ($fldinfo as $fld){ $rd[$ctr]['index'] = $ctr; $rd[$ctr]['fldname'] = $fld->name; $rd[$ctr]['fldtype'] = $fld->type; $rd[$ctr]['flag'] = $fld->flags; $rd[$ctr]['length'] = $fld->length; $rd[$ctr]['inval'] = ''; $rd[$ctr]['outval'] = ''; $ctr++; } ......... I get this on my browser: Unknown element type Unknown element type Unknown element type Unknown element type I'm assuming that at least part of the issue is because I need to translate the actual data in the fetch_field array, but can't seem to find how to do that. I'm not versed in using classes etc, so i'm still doing things procederally for now. Does that matter in this case? I also tried this syntax, which failed miserably foreach ($fldinfo as $fld =>$f){ $rd[$ctr]['index'] = $ctr; $rd[$ctr]['fldname'] = $f['name']; ........ Any suggestions, clues? What a frustrating language this is.... Link to comment https://forums.phpfreaks.com/topic/173052-mysqli_fetch_fields/ Share on other sites More sharing options...
BinaryG Posted September 4, 2009 Share Posted September 4, 2009 type after the array tou want to see the structure of print_r(array_name); ie print_r($fldinfo); and post the data here then we can work out the values Link to comment https://forums.phpfreaks.com/topic/173052-mysqli_fetch_fields/#findComment-912126 Share on other sites More sharing options...
venturemc Posted September 4, 2009 Author Share Posted September 4, 2009 OK, this is what I got, which is what I'm expecting... Array ( [0] => stdClass Object ( [name] => tx_name [orgname] => name [table] => tbl_form_temp [orgtable] => tbl_form_temp [def] => [max_length] => 3 [length] => 50 [charsetnr] => 8 [flags] => 4225 [type] => 253 [decimals] => 0 ) there was more (4 fields total as expected), but don't think it's necessary. Link to comment https://forums.phpfreaks.com/topic/173052-mysqli_fetch_fields/#findComment-912139 Share on other sites More sharing options...
trq Posted September 4, 2009 Share Posted September 4, 2009 You really haven't described what your actually trying to do. Maybe.... foreach ($fldinfo as $k => $v){ $rd[$ctr][$k] = $v; } However, you really need to describe your issue better. Link to comment https://forums.phpfreaks.com/topic/173052-mysqli_fetch_fields/#findComment-912193 Share on other sites More sharing options...
venturemc Posted September 4, 2009 Author Share Posted September 4, 2009 OK, not sure how else to put it..... 1. I'm using the mysqli_fetch_fields function to extract information about a table. 2. The information I want is getting into the $fldinfo array that calls the function (see my second post which results from print_r($fld). 3. I want to store these values in another array ($rd) for future processing 4. All I get in array "$rd" after my loop is "unknown element type" How do I reach the dat that's in $fld_info? The only example I've seen of the use of this function is a print statement, which doesn't help me here. Link to comment https://forums.phpfreaks.com/topic/173052-mysqli_fetch_fields/#findComment-912471 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.