Fatal Error: Uncaught Error: Call to a member function insert() on null

[ad_1]

So I created a custom registration form template (PHP File) in astra theme folder (the theme I currently use) and I used that template in my wordpress site. However, the registration form encounters a critical error upon submission.I saw in the errors log file of wordpress that the error encountered is:

Fatal Error: Uncaught Error: Call to a member function insert() on null

​

I searched a lot of forums and tried adding

global $wpdb;

and

require\_once($\_SERVER\[‘DOCUMENT\_ROOT’\] . $folder . ‘/secret/wp-config.php’);

require\_once($\_SERVER\[‘DOCUMENT\_ROOT’\] . $folder . ‘/secret/wp-load.php’);

both separately and at the same time yet I still encounter the same error. I checked the file path and there’s no error regarding that, the same error appears.

I also checked the database permissions and the wp-config and wp-load files and all the data is correct.

​

I don’t know what else I can do, did anyone else encounter this problem?

Thank you!

​

Edit:By the way here is the code that encounters an error

$wpdb->insert(‘user\_transactions’, array(

‘UID’ => $uid,

‘PRODUCT’ => $product,

‘TRANSACTION_AMOUNT’ => $amount,

‘ENROLLMENT’ => $enrollment,

‘LOCKED’ => $locked

));

[ad_2]
1 Comment
  1. Your $wpdb is null, so you either need to instantiate it, or include it from the global access.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer