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
- Critical Error on Pages – WP_DEBUG Not Showing Anything
- Cannot access non-wordpress subdirectories as wordpress overrides them with a 404 error
- Notice: Constant WP_POST_REVISIONS already defined
- How to stop certain warning logging in error.log?
- Error 404 Page Not Found When Updating a Post or Page
- Why on Earth am I getting “undefined_index” errors?
- Showing error “Function create_function() is deprecated”
- Debugging ‘Object of class WP_Query could not be converted to int’ error
- Update wordpress fail – There has been a critical error on your website
- Add image only in first post
- Sodium compat error
- Fatal error: require(): Failed opening required ‘WP_DIRwp-blog-header.php’
- Can WordPress email the admin about PHP errors, while hiding them from the site?
- : Failed to load resource
- Error trying to publish immediately. Post status = future (Missed schedule error)
- White Screen of Death – wp-admin
- Ajax return code 400
- Form Post results in 404 Not Found [duplicate]
- Where are WP_Errors Saved
- update user information
- Strange glyphs code error
- Sorry, you are not allowed to access this page dashboard
- Homepage Not Found Error [closed]
- Cannot redeclare maybe_create_table()
- Debugging unserialize errors [closed]
- Why can I not execute php files under the wp-includes folder?
- Headers already sent by
- Failed: Filesystem preventing downloads. ( ftpext)
- Code snippet to display ID gives critical error
- I tried to build a theme from scratch and it crashed everything
- Overwrote index.php. When I restored it, I got lots of Notice level errors
- error log bloated by add_view
- Unable to locate WordPress content directory
- Constant WP_CRON_LOCK_TIMEOUT already defined in /htdocs/wp-config.php
- WP Core Update Issue
- can’t get errors
- Cannot load media and I get “PHP Warning: Invalid argument supplied for foreach(“
- Cannot upgrade to 4.0 – get SSL certificate error
- Fatal Error: get_header();
- Error when setting cookie
- Fatal Error wp-settings.php on line 119
- download count29.php whene loading site [closed]
- My new WordPress blog keeps refreshing in Chrome browser
- Custom Post Type Causes Error: Warning: call_user_func_array()
- How to turn off WP error handling, but turn on php error handling?
- Replace old theme that understand old css (vcex_icon_box css_animation)
- Can’t log in to WordPress wp-admin after adding code to functions.php
- White screen after migrating site, but wp-admin works fine. Disabling all plugins, applying default theme and enabling debug mode does nothing
- PHP Warning: mysqli_query(): after updating my websites php from 5.6 to 7.2
- Suddenly get errors in admin when editing post type
- WordPress Bad Request Error 400
- How to identify which php file a plugin is using on page load?
- Why am I getting syntax error, unexpected ‘endwhile’ (T_ENDWHILE) on single.php
- The link you followed has expired. Please try again
- Need Help Understanding Debug Log Errors
- Site has fake users registered with a similar pattern in username and email
- WordPress fails when my post is larger than 1400 words
- How to find the function which is outputting Array
- Weird Parse Error on Uploaded File
- WordPress causing all code to be displayed on line 1. Receiving multiple errors after cleaning cookies and cache
- Why I am having error Call to undefined function get_header()?
- Fatal error: Cannot declare class WP_User_Request, because the name is already in use?
- WP Debug enabled Undefined index error in a widget
- Parse error: syntax error, unexpected T_STRING, expecting ‘,’ or ‘;’ [closed]
- which php or css file has generated an inline style in WordPress that overwrites my css
- Whole right area of wordpress admin dashboard not showing
- WordPress Customizer not loading
- Execute multiple PHP Snippets causes error?
- Apache error log lots of connection_refused
- Lots of warnings and errors instead of my WordPress site – Synology NAS – Intranet
- WordPress 6.1.1 shows deprecated errors with PHP 8.1 & 8.2
- There has been a critical error on this website – wordpress issue after upgrading PHP