Duplicated results

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Perfidus
Forum Contributor
Posts: 114
Joined: Sun Nov 02, 2003 9:54 pm

Duplicated results

Post 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?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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).
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Basically, all I have to say is look carefully at your logic.
Post Reply