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 properly prepare a column name if passed to a stored procedure?
- Genesis framework comments broken?
- Databases – Submitting data from inputs to database [closed]
- Help with a $wpdb MySQL Query
- Fatal error: Call to a member function query() on a non-object
- Custom array from a query only write the last row of the query
- Is it best to avoid using $wpdb for security issues?
- WordPress ajax-action failing because of newline in response
- 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?
- Querying Database with wpdb
- $wpdb returns duplicate posts
- Can’t update multiple rows with $wpdb query
- Mixing variables into an array when inserting values
- How to integrate noimage picture in this code
- Wpdb->insert() doesn’t insert new row after the last one
- dynamic page using php from sql database
- how to get serialized post meta
- How to Update post_modified of all wordpress post
- Correct PHP to output a single result of a Function with SQL Query
- How to get specific attribute from DB
- Basic wpdb update question
- I can’t update my data through $wpdb
- wpdb Cannot Update column in Database
- Output: “Array”
- How to use mysql LIKE with wpdb?
- How to insert wp_users ->user login name to wp_terms when a new user registering?
- Lost in trying to create user database system
- Delete database record using plugin from admin panel
- Pull MySQL data from multiple tables and merge into 1 PHP array
- 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
- How do I prepare strings for insertions as values into a MySQL table?
- Filter results from a serialized string to use on statistics
- wordpress site – using custom database and PHP
- How to use AJAX in WordPress in MYSQL query?
- Searching Posts Programmatically in a WordPress Plugin
- Add valid XHTML closing img tags to WordPress galleries
- Use variable in SQL statement
- Change MySQL PDO connection to a WPDB connection
- WPDB – Read and write value from / to database
- $wpdb->get_results breaking page?
- form $_post action value gets truncated after it passes through two forms
- How to Generate a list of Most Commented post?
- Why won’t this wpdb get_results query return results?
- WPDB secure custom form
- mySQL queries are executed twice on wordpress website
- Undefined variable: row?
- Add row to custom database Table and delete all rows older than 1 day
- Call to a member function get_row() on a non-object, Unable to use global $wbdp inside a plugin
- select a single val though a table in wordpress
- making php value numeric
- Add “alt” Attribute to GD Star Rating Tags
- Using color schemes with Color Picker
- populate select options from extra mysql table data
- Query the links Database
- Remove password protection from all posts
- GD star rating function problem [closed]
- quotes problem in very simple sql
- wordpress sql posts query won’t display the latest post in a specific category
- Display latest post from WordPress Featured Category that is also in X,Y,or Z categories
- WP_Query: How to get results from both meta_key options?
- Export post data with xml to other site using php soap
- MySQL Query Returns Array () In Shortcode
- WordPress get last inserted user id
- Add posts to custom table in database instead of wp_posts
- get_terms with specific id order
- Isn’t Returning Value While Using SELECT COUNT(*) FROM {$wpdb->prefix}
- Passing in MySQL prepare statement parameter separately throwing error
- Convert a column of a table containing an Array as response in HTML
- 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
- add role on WordPress in PHP on a second database
- Trying to create a shortcode to display categories with a specific product tag
- Fetch Data from an external MSSQL Database in a Managed WP hosting
- Run a sql (update) after 12 hours after the user login. Woocommerce users
- Custom User registration system