Page 1 of 1

Duplicated results

Posted: Sun Nov 21, 2004 3:04 am
by Perfidus
The following query:

$getiplist = mysql_query($questions, $link)or die(mysql_error());
$numofips = mysql_num_rows($getiplist);

Gaves me a result of 21.

If I echo the results:

while($row = mysql_fetch_array($getiplist))
{
foreach($row as $column)
echo $row['e_mail_rest']."<br>";}

I get 42 results, each result is being duplicated so I get each twice.
I'm trying to see where am I stumbling but I do not get it.
Where's the stupid mistake?

Posted: Sun Nov 21, 2004 6:22 am
by timvw
RTFM

The optional second argument result_type in mysql_fetch_array() is a constant and can take the following values: MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH. This feature was added in PHP 3.0.7. MYSQL_BOTH is the default for this argument.

By using MYSQL_BOTH, you'll get an array with both associative and number indices. Using MYSQL_ASSOC, you only get associative indices (as mysql_fetch_assoc() works), using MYSQL_NUM, you only get number indices (as mysql_fetch_row() works).

Posted: Sun Nov 21, 2004 10:56 am
by John Cartwright
Basically, all I have to say is look carefully at your logic.