So I've been trying various other threads, but none seem to use MySQLI, nor work.
I'm attempting to query a MySQL table via MySQLI, the convert the returned column into an array to be used later. Here's what I have so far.
$sql = new mysqli("URL", "user", "pass","db") or die ("Not connected");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit;
}
$sql_query = "SELECT Desired_column FROM Table_Name";
$result_array = $sql->query($sql_query);
while($row = $result_array->fetch_row()) {
$rows[]=$row;
}
$result_array->close();
$sql->close();
return $rows;
Call to a member function fetch_row() on Boolean on line 60
Try something like this:
$query = "SELECT Desired_column FROM Table_Name";
$results = mysqli_query($sql, $query);
$rows = [];
while($row = mysqli_fetch_assoc($results)) {
$rows[] = $row;
}
array_push($rows, $row);
to $rows[] = $row;
to reduce function calls