No need to use []… just use simple single quotations (also no quotations does the job):
$sql ="
SELECT
...
WHERE wp_users.`ID` = '$userID'";
OR
$sql ="
SELECT
...
WHERE wp_users.`ID` = $userID";
Related Posts:
- Undefined function mysql_connect()
- MySQL column count doesn’t match value count at row 1 [closed]
- Fatal error: Call to undefined function mysql_connect()
- the_date() not working
- How to return number of found rows from SELECT query
- dbDelta support for FOREIGN KEY
- How to correctly submit a search form and display the result in an independent page
- Check if post of title already exists
- $wpdb->delete column values IN ARRAY()?
- How to make WordPress plugin check for database changes and then do something?
- Custom SQL query to get List of posts with featured image url
- Does WordPress cache get_user_meta() results?
- Delete post revisions on post publish
- Using Echo in ShortCode – Stuck
- Problems migrating WordPress to localhost
- error importing localhost export file to server
- How to sort results from a custom database table
- Update some database fields when post is saved
- Successful or Error Message after running mysql code in functions.php
- sql query to put quotes around numbers in img tag
- PHP/MySQL issues when running WP on EC2 cloud [closed]
- WordPress get pagination on wpdb get_results
- How to create another version of my site based on the same database
- What SQL / WordPress queries would need a nonce?
- Different database query in function.php using mysqli
- Strange wordpress slowness
- Looking for most performant way to execute several similar WP queries within shortcodes
- Setting All Drafts to ‘exclude-from-catalog’ in WooCommerce
- Stumped on migration
- PHP code inside shortcodes
- Show MySQL errors that occur when I excute $wpdb->insert()
- Is XAMPP faster than running LAMP in WSL on Windows 10? [closed]
- WordPress Site Running Extremely Slow on Dedicated Server
- How to securely provide a $_POST var in WP_Query with PHP 7?
- Get updated query results on page after insert in database
- WordPress not reflecting changed of the database
- How can I fix WordPress installation errors?
- How to split links generated into an xml sitemap to avoid exceeding 30 sec maximum execution time?
- Hacked WordPress website /Homepage redirect [closed]
- get_posts() and WP_query limits ‘AND’ conditions to a maximum of 6 for meta value queries in WordPress
- Refresh table data with Ajax
- Database query works fine outside WordPress
- Large Woocommerce Site (83,000 items), What Can I Do? [closed]
- Using custom tables for old posts
- Help with a $wpdb MySQL Query
- How i can obtain all the post meta for a specific post as an array?
- Multiple meta_key in one global $wpdb;
- WordPress member notification
- Can’t Query Custom Table Using $wpdb Method
- Moving wordpress site from localhost to live server using GoDaddy cPanel
- How does WP work in conjunction with a web server?
- $wpdb returns duplicate posts
- Update postmeta after theme switch
- Location of core code for database connection and get_header
- Creating Database Table vs. Adding MetaData to Post & User
- WordPress and MySQL: trying to print data using PHP from user_meta custom field data
- Most commented posts by time period (last 12h, last 24h and etc)
- Hide posts if user is added to it WP_query
- How to unserialize data from MySQL
- Submitting a form, using Ajax, to run a SQL Select query based on user input from the form
- WordPress WP_Query without query GET parameters
- Known Issues in WordPress When Upgrading PHP to ver 7
- Use variable in SQL statement
- Get the id of the row from database on click of a button [closed]
- WPDB secure custom form
- Query the links Database
- SQL error with custom query
- Modify WooCommerce used to get all orders in dashboard
- Display Results of SQL Query on WP site
- Weird fonts showing which are coming from database
- PHP Warning: mysqli_query(): after updating my websites php from 5.6 to 7.2
- Inside Array – “unidentified index” error with “prepare was called incorrectly” despite not calling the prepared statement with wordpress [closed]
- How to optimize and reduce excessive database queries
- How to display MySQL table data which is stored as an array?
- Store GA Client ID in User DB
- How to import woocommerce custom fields data into another site?
- PHP 7.2.18 | Your PHP installation appears to be missing the MySQL extension which is required by WordPress
- Need help with format of nested array in MySQL
- Inserting other fields to existing registration form in a WordPress theme
- Advanced WordPress SQL Query
- Splitting table data to pages with numbers
- Site doesnt work once PHP changed to 7.1
- How to detect if a revision was made by woocommerce or wordpress?
- WordPress WPDB::insert 13th param is always blank (only if format)
- Ajax not updating to database
- can’t delete a row from post_meta table
- MySQL query in WordPress with AJAX
- Processing forms with php to wordpress database
- MySQL queries in WordPress
- How to connect database table to each registered wordpress user.
- retrieve wordpress post-meta using php not wordpress functions
- Splash pages on a high traffic site
- Let users register weight each day and save it in DB
- Submit cf7 form to cfdb as pdf/BLOB [closed]
- How to send push notification in android using php? [closed]
- Custom form that stores data in mysql database
- Putting form result in my database
- How can I update a value of a field depending on outside source?
- Global update of records after import WP All Import Pro
- How to return count number from a wordpress database