You need to add the global $wpdb reference and also add the second parameter required for prepare():
global $wpdb;
$post_id = $post->ID;
$reviewScore = $wpdb->query(
$wpdb->prepare(
"SELECT review FROM {$wpdb->prefix}gdsr_data_article WHERE post_id = %d",
$post_id
)
);
Related Posts:
- $wpdb->get_results(…) returns empty array despite correct query
- WPDB: how to get the value of a field in a custom database table
- Get stock by custom meta field on all Woocommerce variable products
- how to delete 30 day old data using PHP [closed]
- Display fields as values in array from external SQL DB
- Querying wpdb using PHP
- $wpdb->insert() does not Insert record in a table
- Use $wpdb or other PHP script method to find/replace in WP database
- How can I add a new row in a separate database when someone registers via WordPress?
- PHP -> SQL Query with Summing
- Why my query does not run with prepare
- wpdb getting avatars and author url
- WordPress SQL JOIN query
- Database SQL query error
- WordPress SQL Prepare
- Creating multiple tables with Plugin
- How do I get data from my database into my Custom Export Field
- Querying multiple meta_keys in WordPress SQL query
- Can’t send form data to wpdb when URL has query string
- How to get the list of WooCommerce product image of a certain category from database?
- queries inside of a class
- How can I get an XML export of my 1K+ posts WordPress instance?
- How to Join two tables from separate databases within WordPress
- Would manually deleting the dumping data fix a “#1062 – Duplicate entry ‘1’ for key ‘PRIMARY'” phpMyAdmin error?
- Enhanced WordPress Search
- Automatically generate Post/Page from searched Database item?
- register_activation_hook isn’t adding table to DB
- How to display posts of specific category using a custom Query in WordPress?
- Renaming post IDs – Okay to do?
- How to generate page content from database the right way?
- Converting MYSQL to WordPress $WPDB
- How to Fetch values from WP database based on selected option value by onchange using PHP?
- phpMyAdmin displays error when importing database
- Preferred Method of debugging a wordpress SQL calls?
- Why is variable not working on custom sql query using wpdb?
- Can’t get wp_insert_post to work
- Trying to establish connection to External Database
- $wpdb->update with multiple parameters gives error
- How to make a XML/PHP file returning custom field data from page
- wp query foreach deleting record returning only first or last item
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- Error using WordPress $wpdb object to get result from custom table
- How to retrieve the data from the sever and displaying it in a page?
- Can’t update multiple rows with $wpdb query
- Mixing variables into an array when inserting values
- dynamic page using php from sql database
- How to Update post_modified of all wordpress post
- I can’t update my data through $wpdb
- Output: “Array”
- Lost in trying to create user database system
- Delete database record using plugin from admin panel
- SOAP Request/Parsing XML From wp_send_json_success
- Cannot access $wpdb, comes back NULL
- Wpdb get->results to out the the month from the db
- Filter results from a serialized string to use on statistics
- Searching Posts Programmatically in a WordPress Plugin
- Add valid XHTML closing img tags to WordPress galleries
- form $_post action value gets truncated after it passes through two forms
- Add row to custom database Table and delete all rows older than 1 day
- select a single val though a table in wordpress
- making php value numeric
- Using color schemes with Color Picker
- populate select options from extra mysql table data
- GD star rating function problem [closed]
- quotes problem in very simple sql
- Add posts to custom table in database instead of wp_posts
- get_terms with specific id order
- get different meta-data of a complicated query at the same time
- Build A Custom SQL Query for WordPress Search
- How to run complex query using PHP
- Storing huge number of users in wordpress
- WordPress create custom XML RSS feed template
- Custom User registration system
- How to use Multi SQL Database in WordPress?
- Conditional formatting on data fetched from MYSQL
- Looping through custom data in a custom table to display all items in a post
- Displaying SQL query result from user input via wpdb
- How do I create a WP endpoint that retrieves all custom post types that have a tag?
- How to grab data from input and store it into custom table in database?
- Creating a WordPress addon for ContactForm7 submission (.XML file export)
- How can I export data without using any import/export plugin
- Update user_email via php – WP 4.7
- direct query to post_meta table
- Unable to pass variable to database
- What to create new post using wp_insert_post, but it repeat the post infinitely
- Passed variable gets undefined variable error on insert on next page
- Run insert if no entry otherwise run update with ajax
- See output of a sql query while plugin installation in wordpress
- How can I order metaboxes in my posts in WordPress?
- MySQL database migration to WordPress
- How do you get a reference to $wpdb in a PHP script
- WordPress Query -> Ajax Query
- how to display tables via ajax
- Changing regular db connection to $wpdb
- XML WP_Query problem in PHP 8.0 and 8.1
- $wpdb how to make a record lookup
- Error resetting database index using ALTER TABLE in $wpdb->query
- How to sort search result by post_title, then by post_content
- WordPress / PHP: Check if column has value and then check if value in array
- get_var not returning a value when the field contains an apostrophe