Dubya008 Posted August 21, 2010 Share Posted August 21, 2010 I don't know if this is the correct Forum to post this under but I'm trying to fill the values of a recordset into an array. Here is what I have but it doens't work so far. function fetch($info) { return mysql_fetch_array($info); } $Proddb = new mysql; $Proddb->connect(); $result = $Proddb->query("SELECT * FROM Colors WHERE id = '1'"); $row = $Proddb->fetch($result) foreach ($row as $value) { echo $value. "<br>"; } $Proddb-> close(); The array is outputting everything twice does anyone know why? Link to comment https://forums.phpfreaks.com/topic/211383-recordset-array/ Share on other sites More sharing options...
mikosiko Posted August 21, 2010 Share Posted August 21, 2010 here is why http://www.php.net/manual/en/function.mysql-fetch-array.php read the paragraph "Return Values" you can change return mysql_fetch_array($info) for return mysql_fetch_array($info, MYSQL_ASSOC); or return mysql_fetch_array($info, MYSQL_NUM ); Link to comment https://forums.phpfreaks.com/topic/211383-recordset-array/#findComment-1102170 Share on other sites More sharing options...
jcbones Posted August 21, 2010 Share Posted August 21, 2010 Or, just call: mysql_fetch_assoc($info); //or mysql_fetch_row($info); Link to comment https://forums.phpfreaks.com/topic/211383-recordset-array/#findComment-1102182 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.