Check for success of $wpdb->update() correctly

The correct way is with === FALSE which differentiates from equalling zero, which is what a succesful query with no results returns.

if( $wpdb->update($tableName,array('opt_value'=>$cInfo),array('opt_name'=>'showWeatherWidget')) === FALSE)
    //show failure message
else
    // show success message

Leave a Comment