I sort of fixed your query. It needs a table and a WHERE condition to prevent changing all rows. Even a LIMIT 1 at the end won’t hurt.
$rows_affected = $wpdb->query(
$wpdb->prepare(
"UPDATE {$table} SET removed = %s, post_id = %d, user_id = %d, status = %d;",
$cur_date = date('Y-m-d H:i:s'), $postid, $userid, 0
) // $wpdb->prepare
); // $wpdb->query
Just add the WHERE… in the MySQL query. Proper use of prepare is:
$wpdb->prepare($format, $arg1, $arg2, ...); // just like printf()
Related Posts:
- Is it mandatory to use $wpdb->prefix in custom tables
- WordPress and multithreading
- Actions or filters fired when data is saved in a custom table
- Custom Plugin Database relations
- Activation hook not creating table
- How to create database table, add data, update and delete using wpdb via plugins?
- Using WPDB to output raw XML fails because of wp-blog-header.php
- $wpdb->update Issue
- WordPress database error: [Query was empty] – using $wpdb->prepare()
- How to get inserted row IDs for bulk/batch insert with wpdb query?
- Update database record in plugin
- WordPress plugin tables become corrupt
- multiple record insert creating many duplicate records
- Should I use wpdb prepare?
- Default table collation on plugin activation?
- Getting wrong relationship value in $args in wp_Query?
- Not sure the best way to save custom plugin data
- The ideal place for storing persistent PHP objects
- What is the added “complexity” of custom tables?
- Plugin development with unit tests
- How is the data stored in the database?
- Formatting of curly brackets array from WP database to get more readable output
- How to modify post content before writing to database?
- $wpdb->insert is changing a value
- Retrieving custom fields with $wpdb->get_results
- Hello dolly type plugin that allows people to add their own
- How to use mysql IN statement with wpdb update method?
- Database for development
- Is the usage of ON DELETE CASCADE wrong or not allowed on wordpress?
- Version upgrade: can my plugin filter the SQL statements issued during a database upgrade?
- What for the tables ending with the meta used in database of wordpress?
- Creating table with plugin is not working
- How to Download and install plugin database remotely
- Get a custom table to an array
- Update/insert only a column of database table
- How to Create database table when Plugin installed/activated, and delete database when Plugin deleted
- How to insert data to a database table when the field is not yet created?
- Where to store the name of a custom table?
- Subscribe to author?
- include wp-blog-header not working on MAMP
- I’m designing a plugin to create database indexes. Suggestions?
- creating custom function to log actions in plugin
- WordPress database error for query INSERT INTO
- How to connect to AWS RDS external database (not for the core WordPress db)
- Issue regarding $wpdb->prepare()
- How should I store a log for my plugin
- Error on inserting a form value to database
- Are there any scripts, classes, and/or functions built-in to WP for a plugin to export/import its saved data from wp_options?
- Strange issue saving custom field data for a WooCommerce order
- how to search users by ajax live search
- How to perform a heavy and long process in cron jobs?
- Form doesnt save to database
- Adding custom end points, No error line
- Updating Woocommerce Settings API when WordPress Settings API saved and vise versa
- Update results, Before deleting the related category [closed]
- Is using custom table to suit business needs instead of transients a big hit to page load speed?
- Optimising a big WordPress site
- What is the best way to store a few fields?
- How to query custom db table?
- Delete data from database using row action
- How do I have now a duplicated user entry if this is not allowed (and I cannot replicate it)?
- Issue running db create table query from static method
- Alternative functions for mysql_free_result and mysql_ping in wordpress functions
- Make Database query only when option is updated
- Can we intercept user_login and user_pass from a wp_login_form?
- Two different wordpress sites – same server and IP address. Gaining Access to database 1 of 2
- Plugin Development: Storing and Manipulating Data That Fits JSON in Database
- What might be the reason of Couldn’t fetch mysqli_result on another domain?
- How to avoid conflicts with db.php / $wpdb and other plugins that decide to use them?
- How do I debug an error that a plugin is causing?
- $wpdb in php 5.5
- Update plugin settings option_name for big plugin update
- select a single val though a table in wordpress
- Plugin to create Posts and Forums then choose category and parent forum
- dbdelta failing with error: “WordPress database error Table ‘wp_2_myPlugin’ already exists
- Why doesn’t my Table get created?
- How to display specific data from a custom table to logged in users with a custom role
- $wpbd->insert_id is returning null
- Error code when migrate
- How to securely controlling data without keeping it in postmeta?
- WordPress how do I echo SUM from a column of a MySQL table by user id AND type_operation
- WordPress Query doesn’t return the correct value
- WordPress Fatal error: Uncaught Error: Call to undefined function dbDelta()
- Use admin-post to submit form data to external database
- bindParam? WordPress 4.9.5 SQL LIKE statement %s and %LIKE%
- Save in my custom admin page and redirect to the saved object
- Relational / Associate tables using native WordPress functionality
- How to store in the database directly the translation?
- How and when would I implement some code which would take data from one part of the Db and put it in another?
- pull data from wordpress database
- How to implement pagination into a wpdb->result query?
- Ajax not working to insert, query and result data
- Associating special meaning with user id 0
- What method should I use to store my plugin data (multi level menus with options on each item)
- How to add additional field in a table row after creating a table?
- Post data in wp-admin to external database
- Nothing happens on WordPress Update command
- Fixing plugin for wpdb::prepare
- Leveraging Core Functionality in Icon Upload Plugin [closed]
- WordPress database error: [Table ‘bitnami_wordpress.questions’ doesn’t exist]