0

I am using this code to show the users that are administrator:

<?php
while($write = mysql_fetch_array(mysql_query("SELECT * from users WHERE level >1"))){
    echo ''.$write['username'].'';
}
?>

But the page stays loading forever! What is wrong with it?

0

1 Answer 1

7

It's an infinite loop. You're running the query over and over.

$sql = "SELECT * from users WHERE level >1";
$result = mysql_query($sql) or trigger_error("SQL: $sql - Error: ".mysql_error(), E_USER_ERROR);
while($write = mysql_fetch_array($result)){
    echo $write['username'];
}

*Obligatory "switch to PDO/mysqli_" message here.*

1
  • Wanting someone to fill the mysql_* bit for you? There you go (; Commented Jun 21, 2013 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.