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.... Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.