Reputation: 5826
I have seen almost all links but still I am unable to solve my problem.
I am getting $wpdb as null
.
I am checking it like this. I am doing this in single.php file
echo "<pre>";print_r($wpdb);"</pre>";
I have checked about following files. That all are loaded.
Please help me.
EDIT
I want to execute custom query like this.
$entries = $wpdb->get_results( $wpdb->prepare( "SELECT forms.form_title, entries. *
FROM wp_visual_form_builder_forms AS forms
INNER JOIN wp_visual_form_builder_entries AS entries ON entries.form_id = forms.form_id" ) );
this is not working.
Upvotes: 2
Views: 4333
Reputation: 1600
If you read the documentation, you will notice this passage:
Always use the global $wpdb variable. (Remember to globalize $wpdb before using it in any custom functions.)
It's not very clear but I think that means you cannot use $wpdb
outside of a function. What I recommend you do is create a function in your theme's functions.php
file, and call that function from the single.php file.
Upvotes: 2