You had a slight syntax problem, namely the erroneous semicolon.
while($row = $result->fetch_row());
Pay attention to the comma at the end? This means that the next cycle did not run in the cycle. Get rid of it, and it should work.
In addition, you can check if the query really works:
$sql = new mysqli($config['host'], $config['user'], $config['pass'], $config['db_name']); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit; } $query = "SELECT domain FROM services"; $result = $sql->query($query); if (!$result) { printf("Query failed: %s\n", $mysqli->error); exit; } while($row = $result->fetch_row()) { $rows[]=$row; } $result->close(); $sql->close(); return $rows;
source share