I just switched to a new host service and now evey time i run a while loop i get error message. This is my while loop:
$count = 0;
$result = mysql_query("SELECT mid FROM members WHERE logged_on='1'")
or die ("cannot select horse name");
$mid = mysql_result($result,$count,"mid");
while ($mid != "") //member id
{
$result = mysql_query("SELECT name FROM members WHERE mid='$mid'")
or die ("cannot select horse name");
$name = mysql_result($result,0,"name");
//link to that member's page goes here
$result = mysql_query("SELECT mid FROM members WHERE logged_on='1'")
or die ("cannot select horse name");
$mid = mysql_result($result,$count,"mid");
$count++;
}
But when i run this script i get the following warning:
Warning: Unable to jump to row 3 on MySQL result index 12 in /home/whiteoak/public_html/english/updates.php on line 252
Line 252 is the one I've highlighted in red. Can anyone help me? I've tried changing my loop and still no success...
Jade
problems with WHILE LOOPS!!!!
Moderator: General Moderators
I'll leave this as a refrence for other people. I did figure out how to fix this problem even though there is really nothing wrong with my earlier script. I had to switch the script to an array, it was the only way I could get the error message to go away.
This is what it was changed to:
$result = mysql_query("SELECT mid, name FROM members WHERE logged_on='1'")
or die ("cannot select horse name");
while ($row = mysql_fetch_array($result))
{
$mid = $row["mid"];
$name = $row["name"];
//link to that member's page goes here
<a href=visit_home.php?mid=<?php echo $mid; ?>>
<?php echo $name; ?>
</a>
}
Just thought I'd give you a heads up and help anyone else who ever runs into this problem in the future.
Jade
This is what it was changed to:
$result = mysql_query("SELECT mid, name FROM members WHERE logged_on='1'")
or die ("cannot select horse name");
while ($row = mysql_fetch_array($result))
{
$mid = $row["mid"];
$name = $row["name"];
//link to that member's page goes here
<a href=visit_home.php?mid=<?php echo $mid; ?>>
<?php echo $name; ?>
</a>
}
Just thought I'd give you a heads up and help anyone else who ever runs into this problem in the future.
Jade
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK