I developed a query to list fields with checkboxes for the user selection of ones to include in a query result. It was working in the template file (based on page.php). Then I decided to move the logic that I will be using in other templates to a db-functions.php file. Now, I'm getting
Fatal error: Call to a member function get_results() on null in /home/...
printf($the_db)
returns the proper login credentials, but apparently an error because 'affected_rows' = -1
.
I can't find what's missing or misconfigured. Code is below.
require_once($_SERVER['DOCUMENT_ROOT'] . $folder . '/wp-config.php');
require_once($_SERVER['DOCUMENT_ROOT'] . $folder . '/wp-load.php');
//db-setup
function dbsetup($usr, $passwd, $databas, $hst){
global $wpdb;
$the_db = new wpdb($usr, $passwd, $databas, $hst);
}
//disp-field-list
function dbfldfrm(){
$fieldlstress = $the_db->get_results("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.Columns where TABLE_NAME = 'index_records'");