My while keeps looping and i dont know why: code

        <?php
        $result = mysql_query("SELECT * FROM tag WHERE point='$pagename'");
        while($row = mysql_fetch_array($result))
        {
            $result = mysql_query("SELECT * FROM tag WHERE point='$pagename'");
            //username
            echo $row["user"] . " ||";
            //alias check
            $result = mysql_query("SELECT * FROM tag WHERE (user='$my_name' && point='$pagename')");
            if (!$row["alias"])
            {
                echo "As \"" . $my_name . "\"||";
            }
            else
            {
                echo "As \"" . $row["alias"] . "\"||";
            }

            switch ($row["role"])
            {
            case 1:
              echo "Author ||";
              break;
            case 2:
              echo "Illustrator ||";
              break;
            case 3:
              echo "Reader ||";
              break;
            default:
              echo "All ";
            }
        }
        ?>
echo $result;

try this check out put of your query

On line 5 you are assigning the same value to $result over and over again.

$result = mysql_query("SELECT * FROM tag WHERE point='$pagename'");

so while($row = mysql_fetch_array($result)) condition is always true (it is always first row of the table). I would remove line 5.

The $result on line 9n is also causing trouble. What is the goal here? Maybe you post the database structure.

commented: Nice pin point +5

Just a note on quoting strings. It has nothing to do with the error you are getting, just a suggestion. Instead of:

echo "As \"" . $row["alias"] . "\"||";

you can do either:

echo "As \"{$row["alias"]}\"||";

or

echo 'As "' . $row["alias"] . '"||';

It is slightly more readable and easier to debug. But it is your choice what you prefer.

Just remove line 5 as suggested by Broj1 then it will work fine.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.