I can't seem to be able to place the resultset into an array and then use print_r to print out the array. Here's the script:
<?php
require( 'wp-load.php' );
$local = 'xxx';
$user = 'xxx';
$pass = 'xxx';
$data = 'xxx';
$testConnection = mysqli_connect($local,$user,$pass, $data);
if (!$testConnection) {
die('Error: ' . mysqli_connect_errno() . PHP_EOL);
}
echo 'Database connection working!';
global $wpdb;
$result = $wpdb->get_results ( "SELECT * FROM $wpdb->options" );
/* this is commented out but works
foreach ( $result as $row ) {
echo $row->option_id.'<br>';
}
*/
//PART NOT WORKING
$results = [];
while($row = mysqli_fetch_array($result,MYSQLI_NUM))
{
echo "hello"; //never executes?????
$results[] = $row;
}
//$results has all that you need
print_r($results); //empty array???
$testClosed = mysqli_close($testConnection);
if ($testClosed) {
echo "closed";
}
?>