First insert the global.
global $wpdb;
Then You have to check your quotes properly.
$sql = $wpdb->prepare(
"INSERT INTO `$table_name`
(`name`,`email`,`phone`,`message`,`rq`,`url`)
values ($name, $email, $phone, $address, $msg, 1, $url)");
$wpdb->query($sql);
OR
$wpdb->insert('$table_name', array(
'name' => $name,
'email' => $email,
'phone' => $phone, // ... and so on
));
Related Posts:
- order by numeric value for meta value
- Wp get all the sub pages of the parent using wp query
- WP_Comment_Query pagination, delving into the unknown
- Usage of the new “posts_clauses” filter in WordPress 3.1?
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- Sort posts by category name and title
- How to uniquely identify queries?
- Get posts by meta data OR title
- WP_Query ordered by custom field that is a date string?
- How to make an activities stream mixing posts and comments?
- Duplicate Queries
- How to query for a week using key => value WP_Query argument notation?
- SQL query equivalent to WP User Query
- Highlighting Sub topic in a post?
- How to count post type that has a particular term?
- how to retrieve specific product attribute value in an sql query?
- Foreach-generated custom tax queries, each with an ajax “Load more” button
- meta_query on a date range using an array of values
- WP_Query Performance Issues with meta_query
- WordPress custom archive page
- How to detect custom query inside `posts_where` hook?
- Is temporarily overwriting $wp_query a bad idea?
- Query Set Order By Author
- Retrieve or Query Pages by ID
- How to output different posts per page?
- Empty tax_query array returns an empty array
- Different string for specifed post type on posts listing at homepage
- How to orderby meta_value_num with dollar ($) sign
- if/else on custom query gives 200 OK when condition not met?
- How to correctly pass values to wpdb->prepare()?
- Query: offset post list, unless it’s a specific category
- Setting get_queried_object
- remove query arg from url after set query
- difference between like ‘%%%var%%’ and ‘%var%’
- only delete post within query / for each statement (front end)
- How to detect if query is runned from widget?
- Sort query by author: 1 author, then others
- Custom Query num_rows returns wrong amount
- Overwrite YoastSEO meta-tags with another page’s [closed]
- How to orderby multiple meta fields if some fields are empty
- How to duplicate 5 posts out of WP_Query results?
- WP_query sorting can’t sort danish letters (æ, ø, å)
- Slow queries on a huge database
- WP_Query with ‘rand’, but equal number of posts from the taxonomy terms given
- Multisite pagination issue by multi query archive 404
- Query with relation and one without relation using multiple taxonomies?
- How to get list of posts from permalinks?
- Is there a reason why Pages are not publicly_queryable?
- Check return value of get_posts
- Exclude some authors from query
- Sort WordPress Posts Meta value by Week not Day
- 2 wordpress loops showing 1 post from same post type – how to avoid showing the same post?
- Transient api Caches confused
- How can I override one post and make it display content for another post?
- Get multiple users with meta value in one query and populate WP_User class
- Get a list of posts by specific category
- How to check the array values, what WP_Query has brought to me?
- How to add custom meta to ‘pre_get_terms’?
- Shortcode for custom query not returning results when attributes are added
- Should I reset $wp_query?
- Query where ANDing slug values not working
- How to filter query loop block with a search string from the query parameters
- Get specific ACF key and value from all posts – no access to DB
- How to SQL query posts IDs by categories AND authors?
- I am officially missing something about transient posts
- Start Query from 2nd Post without offset
- Display upcoming events in the next 30 days by querying posts with timestamp in custom meta
- Post incorrectly excluded when using “category__in”?
- Query multiple post types, but different order for each
- Display posts ONLY from the current logged in user and current week/year/month Elementor posts
- Any way to use FETCH_KEY_PAIR with $wpdb?
- Query against multiple locations within single custom post type post
- How to get_comments() ordered by date and parent?
- How to query users by post count no less than 10
- WP Query. Ordering posts by another post types meta
- How to make a search query if not found in post table then search in postmeta table?
- WP_Query about meta_key and its array value
- Create global array to compare inside a query
- Adding Category in WP_Query Not Working
- Merge two queries and remove duplicate
- how to show more than 1 post into three columns query
- Using the same WP_Query for shop and widgets in WooCommerce shop
- How can I get all the posts that are related with a specific taxonomy term?
- Fetch only categorized posts
- Custom pagination (Title, date and teaser)
- Filter posts/pages by user_role array
- Pagination in custom query in a category page
- Get a list of the last posts grouped by author and filtered by category
- When should you use WP_Query vs query_posts() vs get_posts()?
- How to query post ids liked by the Author
- Modify query after meta value
- Custom post types loop on a page template
- Showing posts from 4 categories along with all latest posts
- Pagination in WP query with transient API
- Parsing External Table Arguments
- Query posts by meta value and sort by another meta key
- Main loop querying current template’s info only in custom category archive pages, not my posts
- Use meta query only 3 or more results?
- Search results stuck on page 1
- Use value from meta key array for use in WP_Query