Fatal error when using update() in $wpdb class

I am trying to update a custom table in my WordPress database, but I keep getting this error:

Fatal error: Call to a member function update() on null in /Users/jlf/project/wp-admin/controls.php on line 21

This is my PHP:


    $accentColor    = $_POST["accentColor"];
    $donateColor    = $_POST["donateColor"];
    $donateHover    = $_POST["donateHover"];
    $ticketStatus   = $_POST["ticketStatus"];
    $logoPath       = $_POST["logoPath"];
    $characterPath  = $_POST["characterPath"];

    global $wpdb;
    $q_result = $wpdb->update(             // line 21
            'accent_color'      =>  $accentColor, 
            'donate_color'      =>  $donateColor, 
            'donate_hover'      =>  $donateHover, 
            'tickets_status'    =>  $ticketStatus, 
            'logo_path'         =>  $logoPath, 
            'character_path'     => $characterPath
        array( 'id' => 1 ), 
        array( '%s', '%s', '%s', '%s', '%s', '%s' ), 
        array( '%d' )

    if ($q_result) {
        print('<script>window.location.href = "index.php";</script>');
    else   {
        print("<br><a href='index.php'>back</a>");

All of the variables echo their proper values. I’ve globalized $wpdb. What could be going wrong?

Source: wpdb

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.