You did everything right with the globalize, the error message is just telling you that you called a function on $wpdb which does not exists.
Just check prior you do that $wpdb contains the object you’re intersted in:
if (is_object($wpdb) && is_a($wpdb, 'wpdb')) {
$result = $wpdb->insert( 'wp_weights', array( 'user_id' => $userid, 'current_weight' => $weight ), array( '%d', '%d' ) );
}
Alternatively you can add this below the global line to learn more:
global $wpdb;
var_dump($wpdb); // dump variable type and contents.
Additionally try:
require_once( ABSPATH . 'wp-load.php' );
global $wpdb;
You might not have wordpress ready to provide what you need in $wpdb.
Related Posts:
- error_log() output for print_r() appearing on page
- What is the best way to monitor PHP functions/executions?
- How do I set up Debugging?
- error_log is not working as expected in functions.php file
- “Notice: Undefined variable: content” is showing [closed]
- add_sub_menu page() to be replaced by add_theme_page()
- How to show the error causing the ‘There has been a critical error on your website’?
- Warning: Invalid argument supplied for foreach() in portfolio-list.php [closed]
- How to find error in my code when the error message is pointing to WP core file?
- What might cause “junk after document element” error?
- How do you change error reporting to only show errors in WordPress?
- Mute Debug Messages from Plugins
- How to Debug WordPress
- Error message prevents access to WP
- Getting notices on fresh 3.6.1 install
- WordPress: Notice:Object of class WP_Query could not be converted to int in on line
- “Undefined index” error when saving empty array with checkboxes
- Front end empty (i.e. nothing displays); Back end looks fine; What are possible causes?
- WordPress + Buddpyress – troubleshooting server overloading
- Plugin debugging with errors in activation routine
- Unnessary character on post after restore
- How to find which plugin crashes
- WordPress won’t display errors at all
- WordPress White Screen Error
- write developer debug statements to separate log
- I’m getting this ‘PHP Deprecated’ issue
- Platform sh site setup in localhost gets Cookie error
- Error logging in wordpress
- Edit page displays ‘critical error has occurred’ but when debugging is turned on, there are no error messages
- Critical Error on Pages – WP_DEBUG Not Showing Anything
- Why do get_category_by_slug() crashes WordPress 4.8
- WordPress debug messages not displaying
- WP displays “some_strange_number Version” in the bottom right corner
- Preg_Match(): compilation failed unknown property name
- Child Theme Fatal Error [closed]
- How to catch all PHP errors with custom error handler?
- “load-scripts.php” hangs and times out when plupload is requested
- Trying to get property of non-object error with thumbnail
- Warning: Illegal string offset on theme options page [closed]
- @file_get_contents and wp_remote_get
- customize wordpress database error page
- I have an error message coming up after I type in my domain. How Do I get my site back
- Jetpack could not contact wordpress [closed]
- Warning: spl_autoload() [function.spl-autoload] (Term Menu Order)
- PHP if statement works in template files, but not header
- Getting a WordPress Debug Strategy
- Headers already sent by
- Failed: Filesystem preventing downloads. ( ftpext)
- Blog automatically redirected to error page
- Error establishing a database connection error on a site that was working fine previously
- Can not login to wordpress site after resolving white screen of death
- Code snippet to display ID gives critical error
- I tried to build a theme from scratch and it crashed everything
- Errors after upgrading PHP to 7.4 WordPress
- PHP-warning in post-template.php and no loading content on pages
- How to display SQL query that ran in WC_Order_Query?
- Site Address (URL) – causing error 404
- UTF-32be error WordPress
- Overwrote index.php. When I restored it, I got lots of Notice level errors
- How to end a while loop when used in a fetch assoc function [closed]
- After adding my website to a new server, I keep getting a unexpected end of file error, but the file is identitcal to it’s original source
- 500 error for all pages and post after move localhost to server
- 403 forbidden access to my whole site
- Object of class stdClass could not be converted to string in
- error log bloated by add_view
- How can I find the cause of a 500 server error?
- Warning: require_once(/home/onetwo/public_html/wp-config.php): [closed]
- Parse error: syntax error, unexpected ‘}’ [closed]
- Unable to locate WordPress content directory
- Why does this code snippet create a critical error on my site? [closed]
- why would ABSPATH not get defined
- 404 Not found error after update to WordPress 5.0
- Array to string conversion error in PHP 7.2 when returning user role as class
- Keep getting this code reparted again and again?
- javascript variable to wordpress php variable
- PHP E_WARNING being shown despite php.ini [closed]
- Constant WP_CRON_LOCK_TIMEOUT already defined in /htdocs/wp-config.php
- WordPress code problem [closed]
- WP Core Update Issue
- Hooks for post saving make a post-new.php to load latest post’s data
- How to trace an Error when it says nothing about any plugin?
- What’s wrong with this piece of code? [closed]
- White Screen on Site but wp-admin OK
- Dummy data error
- WordPress fonts need to upload with Google fonts?
- add button to specific post
- can’t get errors
- Angular not defined [closed]
- Cannot load media and I get “PHP Warning: Invalid argument supplied for foreach(“
- Cannot upgrade to 4.0 – get SSL certificate error
- How do I debug an error that a plugin is causing?
- require_once() error after moving WordPressto another server
- Internet Explorer cannot display the webpage
- Method Not Implemented GET to wp-admin/post.php not supported
- Fatal Error: get_header();
- Error when setting cookie
- Removed plugin generating error message
- Parse error:syntax error [closed]
- When sorting WP_List_Table, table sorts, but I also get SQL errors
- 403 Forbidden error nginx