I'm new to both PHP and MySQL so it is probably an easy fix but I cannot figure it out. When I put in a query into terminal it returns what I want absolutely fine, but when I used PHP to send the query, it returns an empty array and the result has nothing in it as well.
This is my code for sending the query and then adding it to another array.
include 'mysql.php';
$sql = "SELECT username FROM members";
$result = $conn->query($sql);
$return = array();
while($row = mysqli_fetch_array($results)){
$return[] = $row['username'];
}
mysql.php
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
Thanks in advanced for any help.