PHP MYSQL Endless Loop
Posted
by Neb
on Stack Overflow
See other posts from Stack Overflow
or by Neb
Published on 2010-06-10T11:39:04Z
Indexed on
2010/06/10
11:42 UTC
Read the original article
Hit count: 310
Hi, I have a problem with my php/mysql script. It should only output the while loop once but I am getting unlimited loops and an endless page.
$query = mysql_query("SELECT * FROM users WHERE username ='".base64_encode($_SESSION['username'])."' LIMIT 1");
$result = mysql_fetch_array($query);
if(empty($result)){
echo "No user... Error";
}else{
while($row = $result){
?>
<a href="index.php?user=<?=$row['id']?>"><?=base64_decode($row['username'])?></a> | <a href="javascript:void(0);" id="logout">Logout</a>
<?php
}
}
I have tried a similar script with these same lines and it works perfectly
$result = mysql_fetch_array($query);
if(empty($result)){
echo "No user... Error";
}else{
while($row = $result){
//Something
}
}
© Stack Overflow or respective owner