Your count for that query may be 0. Make sure $wpdb->tablex
is correct.
Also, definitely use $wpdb->prepare
$user_followed = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( * ) AS total FROM {$wpdb->tablex} WHERE type = %d AND active = %d AND user_id = %d", 4, 1, $user_id ) );
Related Posts:
- How do you properly prepare a %LIKE% SQL statement?
- $wpdb and MySQL Create Trigger
- wpdb->prepare function remove single quote for %s in SQL statment
- Alternative to mysql_real_escape_string
- Increment value (value = value+1) of $wpdb->update
- wpdb Custom Meta Data with 2 conditions
- wpdb prepare syntax
- SQL query not working in alphabetical post title/content search
- MySQL LIKE not working
- Proper way to work with wpdb to get user’s firstname
- How to check for empty and not a failure
- Database: Custom table: sprintf value for DateTime column
- Converting mysql to $wpdb
- WP_USE_EXT_MYSQL
- wpdb insert and boolean fields
- Join new table with SQL query
- writing inner join in wpdb
- How to split the a table in database?
- MySQL Rank & $wpdb
- When WordPress Default table, Echo Success. When Plugin Table, Echo Blank
- How do I join a $wpdb query with user meta using default value if not exist?
- How to translate this mySQL query to $wpdb query
- $wpdb select all meta for each post
- $wpdb to insert html form information
- Proper usage of $wpdb->update()?
- WordPress(wpdb class) and mysql stored procedures
- Can’t run database query
- Using WPDB->Insert()
- Active DB queries in WordPress?
- How to stop $wpdb from prepending database name
- WordPress $wpdb get posts from category and sort by custom meta
- How to get INSERT errors from $wpdb?
- Getting Error Trying to Create Table
- How to set MYSQLI_OPT_INT_AND_FLOAT_NATIVE option
- Understanding custom php that reads from WP MYSQL
- How to insert dash (-) into database using wpdb and new_to_publish hook?
- $wpdb->get_var multiple queries in one database check
- List users with the most posts in the last 30 days
- Insert two row in wordpress database
- WordPress $wpdb no result
- PHP variables in mysql query
- MySQL ‘duplicate entry’ error
- User set date and time from frontend doesn’t get stored into database
- Wpdb query with dynamic table name
- get posts whether meta_key exists or not
- when using $wpdb sudden connection rejection without changing anything. Access denied, with errors from repair tool
- How to search usermeta table
- How to add virtual column in wpdb get_result statement
- wpdb insert into point column in db
- WPDB delivers wrong results from complex queries
- $wpdb post type and term query only works when there are no dashes or spaces in the term slug and title
- CONCAT_WS in custom sql query
- Geographical proximity query using post_meta
- MySQL Select within WP Page template
- Saving custom term value to the database in new table
- why is $wpdb->update() causing a DB error from within wp_set_password()
- Initialization of table in database using ‘CREATE … IF NOT EXISTS’
- MySQL error 2006: mysql server has gone away
- #1273 – Unknown collation: ‘utf8mb4_unicode_520_ci’
- what does “/index.php?admin/admin_dashboard” in my url mean
- How to join two tables by multiple columns in SQL?
- How to get size of mysql database?
- SQL – Update multiple records in one query
- mysql update multiple columns with same now()
- Usage of MySQL’s “IF EXISTS”
- Generating a random & unique 8 character string using MySQL
- MySQL > Table doesn’t exist. But it does (or it should)
- Can’t create test file lower test start server mysql
- MySQL delete multiple rows in one query conditions unique to each row
- SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
- Failed to Connect to MySQL at localhost:3306 with user root
- SQL query to update post_date (one post = one single date & time)
- How to copy post titles to post slug in phpmyadmin
- If I consider changing my WordPress DB tables to InnoDB, will it have an effect on the way WordPress works?
- What is the most secure way to set up the MySQL user in WPMU?
- Get the Plugin Which Triggered a MySql Query in WordPress?
- Distinction on meta value on pre_get_posts
- WSoD being caused by this piece of code
- Return terms from multiple taxonomies using $wpdb
- How are multiple WordPress WPDB queries handled?
- Regarding “Insert query error” in wordpress
- $wpdb->insert() does not Insert record in a table
- WordPress plugin overloading with tmp tables
- Site not responding error – taking long to load [closed]
- Mixing variables into an array when inserting values
- Replace a character in all post titles and slugs
- Way to extract wordpress data from folder backup
- wpdb function insert doesn’t work
- Convert a column of a table containing an Array as response in HTML
- I want to share local developement and staging DB — Is this very smart or very stupid?
- WordPress asks to install, but is already installed?
- WordPress Database Query works in phpMyAdmin but not in the code
- Deleting a table row through query
- An SQL query to find orphaned image attachments and their meta
- Simple SQL Query in wordpress
- How to make an sql query to exclude everything but custom taxonomy terms in table wp_terms?
- remove wordpress post links
- SQL get last entry of a specific gravity form
- mysqldump to a tar.gz
- Where is my mysql log on OS X?