First, you’re using prepare() wrong. Should be this:
$wpdb->prepare("SELECT Active FROM testers WHERE user_id = %s", $user_id)
Or even better (%d) represents numeric value as oppose to %s which is string:
$wpdb->prepare("SELECT Active FROM testers WHERE user_id = %d", $user_id)
If you have any debugging enabled, it will throw an error from your code. Which may make your location header not work properly.
Second, the get_var() function indeed returns null when there are no results.
Third, setting a location: header without actually exiting afterwards may cause your header to be overwritten by something else later.
Related Posts:
- Inserting Post Meta From SQL
- How to execute mulitple statement SQL queries using $wpdb->query?
- Delete duplicate rows from wordpress database where a column is duplicate in phpmyadmin
- Query WordPress database by registered date and role
- Size article thumbnails and retrieve them directly from database
- wpdb_prepare with multiple or condition
- SQL Error wp_commentmeta – incorrect table definition
- WordPress and MySQL: how to transfer Meta_key and Meta_Value from one post_id to another
- How do I get the posts within a certain year/date(with sql query)?
- Create table from array with prepare
- Why this query is not showing any result on wordpresss home page?
- Why does changing Database Table Prefixes result in loss of content?
- SQL query to set posts in bulk based on the post content
- DB prefix not updating
- I wanted to Know that how can I give ingore to 0000-00-00 in my config file
- How to create index (sql) to a meta_key?
- Delete all users meta that named: user_avatar
- The MySQL Connection could not be established., before it was joomla but i have change it into worpress
- Migrated to Namecheap, now Trouble with Database & wp-config [closed]
- export individual posts to text files or a single csv file
- SQL query : Select a thumbnail for a media
- why you don’t Implement PDO for access every thing to database
- SQL Query to get post_id from wp_posts and and meta_key(s) from wp_postmeta
- Deleting WordPress posts and media files based on author via MYSQL database
- Can’t connect to MySQL server on ‘127.0.0.1’ (10061) (2003)
- difference between primary key and unique key
- phpMyAdmin – Error > Incorrect format parameter?
- MySQL Database User: Which Privileges are needed?
- Why is my database import losing text widget data?
- Will it break my site if I delete all transient records in wp_options table?
- Please explain how WordPress works with MySQL character set and collation at a low level
- Reset Post IDs to less than 64bit integer
- WordPress database scalability from the code perspective
- Does WordPress use the InnoDB engine for MySQL by default?
- Where are image paths to product category images stored in WordPress database
- Sharing database for collaborative development
- Can I use MariaDB instead of MySQL in wordpress?
- Split WP install between 2 databases?
- Why does dbDelta() not catch MysqlErrors?
- Moving an entire wordpress site from one domain to a new domain and database
- Is altering a default WordPress database table update safe?
- Custom DB_COLLATE (collation) value not working on fresh install?
- What causes the “max_user_connections” warning on WordPress frontend?
- what to do when your WordPress database is too large?
- Change all http to https in mysql databse?
- WordPress and automated MySQL backups to a different host
- Scheduling posts in database
- WordPress site uses MyISAM, should I switch to InnoDB necessary?
- Uppercase to sentence case for post titles
- WordPress mysql table double prefixes
- WordPress database import: Row size too large
- Advanced SELECT query with condtional statements
- Why do mass updates to post_content shows in front end, but not in edit screen?
- Error establishing database connection – high traffic?
- Export / import WordPress database
- Bulk-create posts from SQL database
- Improve performance by removing unnecessary database queries
- Redirecting to old domain after migration website
- WordPress Database Huge wp_usermeta Table
- Switching Databases in LocalHost
- Migrating to WordPress Recipe Plugin and Some SQL Issues
- Unable to set a default serialized array using dbdelta()
- How to prevent/delay MySQL connections when an object cache is used?
- How to fix database error duplicate entry
- How do I convert a MySQL database from utf8mb4 to utf8 encoding?
- WPDB SQL query with prepare() returning variable, not db value
- Problems with moving my WordPress site to another domain/server
- Best practice to limit results in get_row()?
- How to migrate a database from a server to another
- Trouble running $wpdb->query() with last_insert_id
- Moving WordPress site to new domain – database import [duplicate]
- Location of WP default mySQL tables creation file?
- How to display data from db in select list [closed]
- Link multiple user databases together?
- Sql query to get all metadata for a post
- Set a cron job to delete a specific database table table every midnight
- SQL database import #1046 error
- Bulk find & replace on WordPress posts/pages (minus image paths)
- How to import products in host instead of database on wordpress?
- I would like some help wth an SQL query to link posts with categories
- How do I loop/iterate through posts to edit all img tags?
- Where is the HTML-handler part in the wpdb class?
- next comment id number wordpress
- Correct and secure way to access a custom SQL database in a custom PHP template file
- Merging development site with live site
- How to retrieve user data based on role using SQL?
- Missing latest posts and options after DB migration via phpMyAdmin
- Check if a database is well installed
- live site do not update after importing sql database
- How do i get value from wp_postmeta?
- “MySQL server has gone away” since update to 3.8
- featured image not showing up with mysql_connect
- MySQL Database User: Which Privileges are needed?
- Import Excel (or csv) Table with user-data as subscribers to wordpress
- Getting deleted users in database
- Print output of Table Creation
- Uploading to WordPress Database
- Have WordPress Use a Different Database for users
- How to generate PDF dynamically based on values from the database in WordPress
- Count views without get_post_meta