Most likely your values $latitude
and/or $longitude
are not what you expect them to be. So radians($latitdue)
becomes radians()
or radians('')
.
For getting a single row, get_row()
is usually the better choice instead of get_results()
.
$zipdetail = $wpdb->get_row( "SELECT * FROM `li_zipcode` WHERE `zip_code` = '$zipcode'", OBJECT );
If $zipcode
is coming from an untrusted source (e.g. user input), make sure to use a prepared statement:
$zipdetail = $wpdb->get_row(
$wpdb->prepare(
'SELECT latitude, longitude FROM `li_zipcode` WHERE `zip_code` = %d',
$zipcode
),
OBJECT
);
Related Posts:
- Get posts by menu ID
- Slow SQL_CALC_FOUND_ROWS Query
- Order by custom table and multiplication
- why update and delete query not worked in custom table?
- How to implement a new row_count method in WordPress?
- WP_Query with page_ids in arguments without a result
- Why last row deleted when refresh page
- Fix wp_term_relationships slow query in get_posts
- WP_Query always returning the last custom post
- SQL query into to WP query
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- Return only Count from a wp_query request?
- Use REGEXP in WP_Query meta_query key
- Order by DESC, ASC in custom WP_Query
- How to prevent execution of default query, while preserving ability to use WP_Query in template?
- Should I use Transients with W3 Total Cache APC Caching? [closed]
- find a random blogid across my multisite network that has at least one post published
- SQL query equivalent to WP User Query
- What’s wrong with this WP query?
- Stop all SQL_CALC_FOUND_ROWS wordpress queries
- How to count post meta key values for all posts in database
- Group posts by meta_key
- WP_Query hit max joins… How else can I build a search function that uses custom fields?
- Would this post meta be better added to the post table rather than post_meta table
- Order By Multiple Meta Fields
- meta_query on a date range using an array of values
- WP_Query Performance Issues with meta_query
- if statement on database query
- How to speed up wp_query, took more 5s to run against 100k posts
- Get the post permalink within the loop but without additional DB query
- Filter WordPress posts by between parameter
- How To Get Some Data From WordPress Database Using WordPress $wpdb Query?
- Mysql query LIKE not working
- How to get posts on a specific date – WP Query
- Using WP_Query and WP_Meta_Query Outside of WordPress
- How WordPress attaches its Featured Images with posts?
- How to find exact match for search term in WP_Query? What is the additional string added in LIKE query in WP_Query?
- Improve wp query perfomance on large db
- wpdb custom post_type problem
- Performance when getting post meta for post retrieved by meta value
- Order by summing multiple values
- querying data via $wpdb and get_row
- wp_Qwery works to slow
- inserting a post from an extern php file but post content doesn’t show on wp site
- No results found from a $wpdb->get_results() query when trying to join more than one meta key query
- Query most popular terms by taxonomy over 2 week period
- Which is faster wpdb & get_row or wp_query & ge_post_meta?
- How to access custom WordPress database tables
- how update data through ajax and jquery
- Is it possible to query from external database? [duplicate]
- List of ways to access WordPress database?
- Specify strict ‘order by’ in WordPress query
- How to set up hierarchical relationships without using plugins / meta query
- How I can change the condition or compare operator for WP_Query in pre_get_posts
- Does WordPress have something like Drupal’s DB API?
- Slow Query On Search
- Wpdb->query result show 1 but is not an integer
- Why having more than 10 clauses in WP_Query results in some outputs being dropped?
- mysql query order by
- Storing an array of objects related to each user
- WP Query – filtering terms with regex
- Function to retrieve IDs of posts, cache results, and improve wp_query
- Issue with data array format
- get_var is neither a string, integer, or array …?
- SQL query injection with fifu image
- What database state changes happen after a post is manually “updated” with no changes?
- WP Query – grouping posts by same meta key, adding together values from another key
- Woocommerce Get Orders By Meta Value
- SQL to join u3g_users & u3g_meta_value with repeating data
- wp query search multi terms
- INNER JOIN custom tables – SQL Query
- use mysql variable in a $wpdb->query to reindex a column?
- How to get meta key list efficiently?
- Translating WP query into to SQL query
- WordPress Query optimaization for slow query
- update_post_meta performance in a loop woocommerce
- update_post_meta performance in a loop woocommerce
- Sorting query_posts() with a complex orderby filter
- Case insensitive ORDERBY in wpquery
- WP_Term_Query->get_terms() very slow query for WordPress filter
- Query postmeta based on meta_value, return array of post_id
- Order Posts By Custom Field That is an array of objects
- Separate by Category Post Type
- I removed the “wp_rm_logs” table and am constantly getting this error
- pull data from wordpress database
- Slow query when selecting with large meta query or post__in
- Track write actions to the database
- Include post_status check within $wpdb query
- Website goes slow down after importing long database
- option select form always deleting the sql query
- Get a list of the last posts grouped by author and filtered by category
- meta_query dates from an array
- Different sql queries count indicator on the main page [closed]
- Custom query_posts() parameter
- WordPress query very slow on +/- 300k DB entries and 7 INNER JOIN
- 294 Queries on Mainpage of WordPress
- how to add limit records in wordpress query
- WP_Query by meta key not returning any posts
- Execute multiple PHP Snippets causes error?
- Bulk delete comments, foreach loop