Author Topic: Mysql_fetch_array() isn't providing text results for some odd reason...  (Read 567 times)

Offline 133794m3r

  • Level 22
  • *
  • Posts: 265
  • Reputation: +2/-0
    • View Profile
For some reason this command is just bringing up well... numbers basically i guess saying if it's positive or false. What i'm doing is trying to get all of the game's items put them in array for the moment then put them on the page in a tad bit so i can well see them and help me later on. Here's the code for it but it's not seeming to work out for some very odd reason. It just shows "1" for all things meaning that's valid i'm guessing.

Code: [Select]
$item = array(
        'id' =>array(),
        'name'=>array(),
        'maint type'=>array(),
        'rarity'=>array(),
        'stack size'=>array(),
        'sub type'=>array(),
        'ilvl'=>array()
    );
    $conn = mysql_connect($dbhost,$dbuser)
or die ('Error connecting to mysql');
    mysql_select_db($dbname);
    $query = 'SELECT * FROM item';
   $result = mysql_query($query);
    while($row = mysql_fetch_array($result,MYSQL_BOTH)){
        global $i;
        $item['id'][]=$row[$i]['id'];
        $item['name'][]=$row[$i]['name'];
        $item['main type'][]=$row[$i]['main_type'];
        $item['rarity'][]=$row[$i]['stack_size'];
        $item['sub type'][]=$row[$i]['sub_type'];
        $i= $i++;
    };
echo $item['id'][0],$item['name'][0],$item['main type'][0];
Is there any way to get it to actually show the bloody text within the column? I thought that's what i was doing via this thing... but who knows.

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,134
  • Reputation: +26/-1
    • View Profile
SQL results are 1D array, not 2D.

$item['id'][$i]=$row['id'];

Offline 133794m3r

  • Level 22
  • *
  • Posts: 265
  • Reputation: +2/-0
    • View Profile
SQL results are 1D array, not 2D.

$item['id'][$i]=$row['id'];
i feel rather stupid now since all the ones i read about were acting like it's 2d so i was like oh ok so it's 2d now ok.... that got it working so now that's done. Thanks Chris.

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal