I am using the below code to get the users list from my db:
if ($result = mysqli_query($mysqli, "SELECT user_name, name, surname, avatar, user_email FROM users")) {
while ($row = $result->fetch_assoc()) {
$username[] = $row["user_name"];
$user_email[] = $row["user_email"];
$user_name[] = $row["name"];
$user_surname[] = $row["surname"];
$avatar[] = $row["avatar"];
}
$result->close();
}
But I get the below error:
Fatal error: [] operator not supported for strings
$username, $user_email, ... etc) as arrays before using them?