I am writing a simple php registration page using MySQL as the database. I am quite new to it and I came across this error:
Parse error: syntax error, unexpected
T_ENCAPSED_AND_WHITESPACE, expecting
T_STRING or T_VARIABLE or T_NUM_STRING
in C:\xampp\htdocs\w4wregister.php on
line 34
I have gone through the little bit of code that I added that caused that error for the past hour and cannot see anything wrong with it. Below I have the code I added. I believe I was able to narrow it down to the while statement but I gave the other code for context.
if($r) {
echo "<h1>Thanks for registering!<h1><br/><h2>Current Users:</h2>";
$q2 = "SELECT username AS users FROM users ORDER BY registration_date";
$r2 = @mysqli_query ($dbc, $q2); //gets all users
if ($r2) {
echo '<table cellspacing="3" cellpadding="3" width="25%"><tr><td>Username</td></tr>';
while ($row = mysqli_fetch_array($r2, MYSQLI_ASSOC)) {
echo "<tr><td> $row['users'] </td></tr>";
}
echo "</table>";
} else {
echo "Hey, that didn't work!";
}
Change:
To:
Another option would be:
Or even:
See the echo for more examples of how to employ variable interpolation.