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 return number of found rows from SELECT query
- $wpdb->delete column values IN ARRAY()?
- How to make WordPress plugin check for database changes and then do something?
- How to display multiple Post meta_key/meta_values by SQL query
- How to display only first value of database column in WordPress
- Print out WordPress user ID – two sites with same code but different output
- Can’t use get_results() in ajax query
- Database “Migration” for Plugins?
- How can I export post data in xml format?
- List of posts by day of the week
- Export WordPress Table to CSV from page
- WordPress get pagination on wpdb get_results
- What SQL / WordPress queries would need a nonce?
- How to limit the content coming from wordpress shortcodes?
- $wpdb->flush(); breaks the loop
- Show MySQL errors that occur when I excute $wpdb->insert()
- database interactions using OOP
- Echo a hierarchical list of post data from custom fields
- WSoD being caused by this piece of code
- Update results, Before deleting the related category [closed]
- How WordPress reacts to a lack of memory of the server [closed]
- wpdb php get_var query to get ID for URL image doesn’t work for ID over 999
- How to split links generated into an xml sitemap to avoid exceeding 30 sec maximum execution time?
- Archive post by meta value + 24hours
- Database query works fine outside WordPress
- 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
- Is it best to avoid using $wpdb for security issues?
- $wpdb returns duplicate posts
- Can’t update multiple rows with $wpdb query
- Mixing variables into an array when inserting values
- dynamic page using php from sql database
- Correct PHP to output a single result of a Function with SQL Query
- Output: “Array”
- How to use mysql LIKE with wpdb?
- Delete database record using plugin from admin panel
- Wpdb get->results to out the the month from the db
- 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
- Use variable in SQL statement
- WPDB secure custom form
- Add “alt” Attribute to GD Star Rating Tags
- Query the links Database
- WP_Query: How to get results from both meta_key options?
- MySQL Query Returns Array () In Shortcode
- Passing in MySQL prepare statement parameter separately throwing error
- Convert a column of a table containing an Array as response in HTML
- Build A Custom SQL Query for WordPress Search
- How to run complex query using PHP
- Storing huge number of users in wordpress
- add role on WordPress in PHP on a second database
- Trying to create a shortcode to display categories with a specific product tag
- Custom User registration system
- How to use Multi SQL Database in WordPress?
- MYSQL TIMESTAMP when adding DATE_FORMAT then the output is blank, PHP conflict?
- Conditional formatting on data fetched from MYSQL
- Woocommerce – get daily sales meta
- Running a PHP SQL script on a wordpress page
- WordPress search query, how to modify the sql
- Modify post image in full size
- problem in using wpdb->prepare and a string placeholder
- Inserting other fields to existing registration form in a WordPress theme
- Advanced WordPress SQL Query
- direct query to post_meta table
- can’t delete a row from post_meta table
- MySQL query in WordPress with AJAX
- Sum of Custom Meta written by Authour
- Order by in foreach
- How to fetch results from database
- See output of a sql query while plugin installation in wordpress
- Using the same shortcode to show any table from the database
- AJAX with Selectbox Plugins (Select2, Chosen, Selectize)
- how to iterate through xml data?
- inner-wrap div pushing custom table far down on page
- I have an error WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version
- SQL query to retrieve the number of WordPress posts with all given categories
- Putting form result in my database