Firstly, as a PHP rule, you don’t need to echo a variable when doing a string concatenation.
Secondly, you need to prepare your query when adding a variable inside.
So your query would become like this:
$prepared = $wpdb->prepare(
"SELECT meta_value FROM wp_woocommerce_order_itemmeta WHERE meta_key = '_wc_checkout_add_on_label' AND order_item_id = %s",
$orderID
);
$size = $wpdb->get_results( $prepared );
Related Posts:
- Transaction when using WP functions rather than vanilla SQL?
- How to get the list of WooCommerce product image of a certain category from database?
- How to make WordPress plugin check for database changes and then do something?
- 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?
- register_activation_hook isn’t adding table to DB
- What SQL / WordPress queries would need a nonce?
- Importing Geo data into wordpress database
- WP_Query adds “(wp_posts.ID = ‘0’)” so no results are returned
- $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?
- Pull MySQL data from multiple tables and merge into 1 PHP array
- mySQL queries are executed twice on wordpress website
- making php value numeric
- Database SQL query error
- How to run complex query using PHP
- Inserting other fields to existing registration form in a WordPress theme
- SQL Query Search page
- can’t delete a row from post_meta table
- Conditional statement within WP SQL query
- SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens on line 102
- dbDelta support for FOREIGN KEY
- How to correctly submit a search form and display the result in an independent page
- How to use update and delete query in wordpress
- How to implement WP_List_Table? WP_List_Table giving array instead of a value in listing table
- Does WordPress cache get_user_meta() results?
- Using Echo in ShortCode – Stuck
- Show only one post for each author ( Page loads too slow )
- WP database error for comments_popup_link()
- Database “Migration” for Plugins?
- No wp-config.php file on local install of wordpress – site still displays
- Use ajax to update_post_meta
- List of posts by day of the week
- How to display posts of specific category using a custom Query in WordPress?
- Is the outdated PHP mysql extension a requirement for WordPress 4.6?
- Different database query in function.php using mysqli
- Get WooCommerce product details and transfer them to a custom DB table
- How can I export posts with featured images, without download them
- How to securely provide a $_POST var in WP_Query with PHP 7?
- Create WP_Query to search for posts by their categories or their parent/child categories
- WSoD being caused by this piece of code
- How to display data from custom table in wordpress phpmyadmin
- Calculating a large number of MYSQL queries as customshort codes, slow
- Update results, Before deleting the related category [closed]
- Replacing mysql_escape_string in a custom plugin when moving to PHP7
- Weird 404 URL Problem – domain name being placed at end of urls
- database sent to a JSON file
- Databases – Submitting data from inputs to database [closed]
- Is it best to avoid using $wpdb for security issues?
- Mixing variables into an array when inserting values
- wpdb prepare insert table doesn’t work
- Should I use WordPress to skin a database website?
- dynamic page using php from sql database
- WordPress Custom SQL Table with UserID Filter for results
- Correct PHP to output a single result of a Function with SQL Query
- How to use mysql LIKE with wpdb?
- wordpress site – using custom database and PHP
- How to use AJAX in WordPress in MYSQL query?
- Searching Posts Programmatically in a WordPress Plugin
- Live search from database table
- form $_post action value gets truncated after it passes through two forms
- Why my query does not run with prepare
- wpdb getting avatars and author url
- phpMyAdmin error #1062 – Duplicate entry ‘1’ for key ‘PRIMARY’
- Add row to custom database Table and delete all rows older than 1 day
- Using color schemes with Color Picker
- WordPress SQL JOIN query
- How to create Loop code for Menu using WordPress?
- How to WP_Query posts order by parent title?
- Convert a column of a table containing an Array as response in HTML
- Error establishing a database connection (Set-up locally)
- Trying to create a shortcode to display categories with a specific product tag
- How to use Multi SQL Database in WordPress?
- how to get data from two different table from wordpress database
- Passing Current User ID into SQL statement
- How to insert multiple rows and columns in database using array
- Woocommerce – get daily sales meta
- WordPress mysql deos not work with php7
- WordPress search query, how to modify the sql
- Windows Setup: Error establishing a database connection
- WP + MySql db / PHP
- WAMP SERVER Command Prompt SET PATH=%PATH%
- append data to mysql table via submit button coded in php – not working
- How to do a MySql query in WordPress?
- How can get all users by current user meta (array)?
- Add two or multiple functions in WordPress Post or Page
- direct query to post_meta table
- Processing forms with php to wordpress database
- How to set max users to 17.000
- How to connect database table to each registered wordpress user.
- Using the same shortcode to show any table from the database
- I am unable to fetch json data from wp_db
- How to send push notification in android using php? [closed]
- How to set variable to specific field when querying
- Search results always returns “No results” no matter what
- Getting invalid user ID error when creating a new user with wp_insert_user
- Custom form that stores data in mysql database
- Retrieve data from external database and insert back in
- Trying to GET data with ajax from database and show in fullcalendar