I have problems in pointing to the database in Wordpress. I have tried to include global $wpdb and it does not work. And I have also done PHP include for the wp-load.php
, wp-db.php
, wp-config.php but still no fix.
It says,
Fatal error: Call to a member function get_results() on a non-object in C:\xampp\htdocs\wordpress\wp-content\themes\cv_test\searchresult_details.php on line 47
Sorry, I'm a beginner in Wordpress development. Any help is appreciated. Thanks.
include_once('http://localhost/wordpress/wp-config.php');
include_once('http://localhost/wordpress/wp-load.php');
include_once('http://localhost/wordpress/wp-includes/wp-db.php');
function retrieveClientDesc()
{
global $wpdb;
$query = "SELECT client_desc FROM wp_client WHERE client_name = 'Cal'";
$result = $wpdb->get_results($query, OBJECT);
for($i = 0; $i<=count($result); $i++)
{
$clientDesc = ($result[$i]->client_desc);
echo $clientDesc;
}
print_r($result);
}
This is part of the codes. It keeps says my $result section has a fatal error.