Array is turning a into string

Viewed 37

I am trying to show a list of the users friends, but it keeps telling me that

Array to string conversion in /opt/lampp/htdocs/Root folder/messaging.php on line 40

and then it displays SELECT username FROM users WHERE user-id=Array. The second part of the thing is supposed to convert the user-id into usernames.

include 'databaseconn.php';
if (isset($_POST['friends'])) {
  $sql = "SELECT user_two FROM friends WHERE user_one=" . $_SESSION['user-id'] ."";
  $result = mysqli_query($conn, $sql);
  foreach ($result as $friend) {
     $sql = "SELECT username FROM users WHERE user-id=" . [$friend] . "";
     $result = mysqli_query($conn, $sql);
     echo "<button><p>$result</p></button>";
  }
} 
0 Answers
Related