Hi there,

I've got a mysql query that I KNOW returns only one record.
I'm then imploding it - but when I look at the resulting string, every field in the query appears twice.....

	$RetQ=mysql_db_query($DBname,"SELECT * from StoreBox WHERE ClientID = $ClientID", $Link);

$RetR=mysql_fetch_array($RetQ);
$oldvalues=implode("|",$RetR);
echo $oldvalues;

So rather that seeing 'John|Doe|Builder' as I expect (and the database contains) $oldvalues contains 'John|John|Doe|Doe|Builder|Builder'. I know the mysql table is OK because I looked!

What's going on then?

    That's because mysql_fetch_array acts like mysql_fetch_row AND mysql_fetch_assoc. It stores
    data twice, with numeric keys and with string keys. Use either mysql_fetch_row or
    mysql_fetch_assoc or give mysql_fecth_array a second parameter, which can be found in
    manual (MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH).

    "mysql_fetch_array() is an extended version of mysql_fetch_row(). In addition to storing
    the data in the numeric indices of the result array, it also stores the data in associative
    indices, using the field names as keys."

    -Cursed

      Write a Reply...