I am using a sql query to access information to display on a wordpress page by adding the below code to a page template. I know the query works as I've tested it in phpmyadmin.
$rows = $newdb->get_results("SELECT TrainerName FROM trainers"); echo "<ul>"; foreach ($rows as $obj) : echo "<li>".$obj->Name."</li>"; endforeach; echo "</ul>";
and I added this is my functions.php file
$newdb = new wpdb();
I can't get it to work though, I get an error "Warning: Invalid argument supplied for foreach() ..."