0

Guys, i am getting an unexpected T_While Error on my code, I cannot figure it out. can you help?

<?php

     $sql = "SELECT id, u_name, u_email, subj, phone FROM tb_cform ";

    $result = $conn->query($sql);

    echo '<table><tr><th>Name</th><th>Email</th><th>Subjec</th><th>Phone</th></tr>';
    if ($result->num_rows > 0) {
            while($row = $result->fetch_assoc()) {
            echo "<tr><td>".$row["u_name"]."</td><td>".$row["u_email"]."</td><td>".$row["subj"]."</td><td>".$row["phone"]."</td></tr>";
        }
    } else {
        echo "0 results";
    }
    echo "</table>";
    $bd->close();

    ?> 
4
Contributors
4
Replies
27
Views
4 Months
Discussion Span
Last Post by diafol
0

I was researching that t-while error and it does appear to happen when the statement is incorrect in some way.
Now it doesn't pop out at me why the while statement is failing so it's back to you to debug the failing line.
https://www.google.com/search?q=debug+php finds how to debug. Now in your system you set a breakpoint then examine the contents of the while tests and see where it went off the rails.

0

Ther's nothing obvious from the snippet, but watch out for unbalanced braces or unterminated lines - but watch out for them upstream as it could be simply telling you - "Wow! Wasn't expecting a while statement there."

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.