Please help with a PHP while loop! PHP noob here :)

I’ve debugged my PHP code and found the error in this exact statement (it does connect to the DB, and works if I remove this code). But right now It just produces a blank page. :frowning:

while($row = $result->fetch_assoc()) {
    echo "<br> ID: ". $row["id"]. " - Selected Username: " . $row["username"]. " " E-mail " . $row["email"]. " " Password: " . $row["password"]. " " Referral: " . $row["referral"]. " IP: " " . $row["ip"]. " Request Date: " " . $row["date"] . "<br>";
}

Help please! Thanks!

You have several extra double-quotes. If you set php’s error_reporting to E_ALL and display_errors to ON, in the php.ini on your system, you would be getting a php syntax error that would help find the problem.

You should use the simplest syntax that works, with the fewest different types of elements in it. You can put php variables inside a double-quoted string (add {} around array elements.) The following is equivalent, without all the extra quotes and dots for concatenation -

echo "<br> ID: {$row['id']} - Selected Username: {$row['username']} E-mail: {$row['email']} Password: {$row['password']} Referral: {$row['referral']} IP: {$row['ip']} Request Date: {$row['date']}<br>";
2 Likes

I’ve never tried anything like that before and was following a seemingly outdated tutorial. Your code worked perfectly, thanks so much!!! :smiley:

Sponsor our Newsletter | Privacy Policy | Terms of Service