You want the query to look like this:
SELECT email FROM wp_my_users WHERE email="[email protected]"
instead of this:
SELECT email FROM 'wp_my_users' WHERE email="[email protected]"
So try to construct your query with:
$sql = "SELECT email FROM {$my_table_name} WHERE email = %s";
$result = $wpdb->get_var( $wpdb->prepare( $sql, $email_address ) );
where you don’t need to escape the table name, since it’s constructed it in a safe way.
Related Posts:
- Using wpdb to connect to a separate database
- How to fetch Data in WordPress using MySQLi or $wpdb
- wpdb->insert multiple record at once
- How to define composite keys with dbDelta()
- Inserting Post Meta From SQL
- Why does dbDelta() not catch MysqlErrors?
- What causes the “max_user_connections” warning on WordPress frontend?
- How to execute mulitple statement SQL queries using $wpdb->query?
- Database slowdown after update to 3.4.1
- wpdb_prepare with multiple or condition
- Advanced SELECT query with condtional statements
- Redirecting to old domain after migration website
- Create table from array with prepare
- WordPress running SQL query to update database from form
- Have working sql query… trying to adjust it to use $wpdb
- Custom WordPress Table wpdb
- Best practice to limit results in get_row()?
- Trouble running $wpdb->query() with last_insert_id
- Query Column of Specific ID from Database Table
- How to create more than one new wpdb object?
- How to connect and insert data in database of wordpress?
- How to escape percentage sign(%) in sql query with $wpdb->prepare?
- “BS_” rows in postmeta table
- Where is the HTML-handler part in the wpdb class?
- WordPress Database Query works in phpMyAdmin but not in the code
- insert data from a form:: Warning Empty query mysqli::query()
- How can I get $wpdb to show MySQL warnings?
- How To connect to the same WordPress database with different database user
- using same mysql user with many databases
- Uploading to WordPress Database
- Can’t connect to MySQL server on ‘127.0.0.1’ (10061) (2003)
- phpMyAdmin – Error > Incorrect format parameter?
- Why is my database import losing text widget data?
- How to return number of found rows from SELECT query
- Will it break my site if I delete all transient records in wp_options table?
- Get error messages when $wpdb->insert() returns false?
- Does dbDelta delete columns as well?
- Reset Post IDs to less than 64bit integer
- Why does $wpdb return strings for mysql integer values?
- Does WordPress use the InnoDB engine for MySQL by default?
- $wpdb->prepare() warning in WordPress 3.5
- Inserting data into custom tables
- Can I use MariaDB instead of MySQL in wordpress?
- Custom DB_COLLATE (collation) value not working on fresh install?
- $wpdb variable throw this error Call to a member function get_results() on a non-object in
- Activation hook not creating table
- WordPress and automated MySQL backups to a different host
- Size article thumbnails and retrieve them directly from database
- WordPress site uses MyISAM, should I switch to InnoDB necessary?
- Getting all the users who have author privilege
- WP Database Table to CSV file
- WordPress database import: Row size too large
- Why do mass updates to post_content shows in front end, but not in edit screen?
- Handling large N data in WordPress
- WordPress choose wrong database
- Improve performance by removing unnecessary database queries
- A MySQL DB within a MySQL DB
- Switching Databases in LocalHost
- Is there a way to recover the table wp_term_relationships?
- Does WordPress $wpdb functions wait when table is locked?
- Trouble Migrating all data blog from WordPress.com to WordPress.org
- Unable to set a default serialized array using dbdelta()
- $wpdb error (Call to a member function insert() on a non-object)
- Problem in using wpdb
- Clear Terms from Taxonomy for Specific Post IDs?
- Why does changing Database Table Prefixes result in loss of content?
- Moving WordPress site to new domain – database import [duplicate]
- Buddypress avatar image in database [closed]
- $wpdb->get_var – What value is returned when zero records are found?
- Installing local to live WP into subdirectory
- add_post_meta — not working
- Select From wpdb – Author/User Directory page
- Only allow user to access a link once a year, based on their joining date
- Counting post and changing roles in mysql database. Query not code
- $wpdb->insert not inserting all rows
- MSQL database wp_postmeta has meta key tve_revision
- wpdb Insert unknown post data dynamic foreach loop
- Insert NULL value using prepare()
- I imported an restore an database and It shows #1067 – Invalid default value for ‘user_registered’
- Help with $wpdb on custom code
- How can I find user role in Mysql?
- $wpdb->insert duplicating rows
- How to rerieve comments and their replies from DB
- Featured image from custom to WordPress database
- Delete all users meta that named: user_avatar
- mySQL database size large, but tables size less
- Using $wpdb to insert data into a table
- spambot registering without providing email or password, bypassing registration process
- After renaming MySQL database, I can no longer access my Blog page
- Call to a member function insert()
- I have include wp-config, should I add global $wpdb also?
- Can’t Install WordPress (local) Failed to open file wp-includes/wp-db.php
- Create a new table on the database and save parameters from a contact form
- Widgets with *internal* links do not display after database migration
- Creating Tables in WordPress Database
- How to back-up a database on IIS
- $wpdb->prepare returns empty array
- Importing Concrete5 content to WordPress
- why you don’t Implement PDO for access every thing to database
- WordPress database connection failed, while mysql client is working [closed]