The main problem, I see in your code, is that you use query method of wpdb and assume that it is PDO statement object…
But it is not.
Take a look at wpdb Codex:
https://codex.wordpress.org/Class_Reference/wpdb
query method is used to run custom queries on DB – that’s all.
What you want to use is get_results.
And BTW, seriously, do never concatenate user input with SQL statements. Such data should ALWAYS be escaped properly – otherwise you create SQL Injection vulnerability. You can use prepare method to create safe queries in WP.
I also don’t think you should echo wp_send_json_success – I’m pretty sure this function already echoes values…
And one more thing… Your hooks are wrong. You send action wc_get_..., but then use hooks like wp_ajax_call_wc_get... (so your php code assumes the action is call_wc_get....
Related Posts:
- How to use AJAX in WordPress in MYSQL query?
- MySQL query in WordPress with AJAX
- How to return number of found rows from SELECT query
- Can i use php sql functions instead of $wpdb?
- $wpdb->delete column values IN ARRAY()?
- Custom query to get post names beginning with a digit
- simple wordpress ajax plugin not working when not logged in
- Jquery ajax to custom php file: returning blank data
- Can’t use get_results() in ajax query
- Is the regular ajax request method safe or I should use admin-ajax.php?
- Use ajax to update_post_meta
- AJAX in WordPress, sending coords data to MySQL and show after into map
- WordPress get pagination on wpdb get_results
- Converting MYSQL to WordPress $WPDB
- How to Fetch values from WP database based on selected option value by onchange using PHP?
- Why is variable not working on custom sql query using wpdb?
- Show MySQL errors that occur when I excute $wpdb->insert()
- Any possible way to make $wpdb->get_results() return anything else than array?
- Checking for new message using AJAX and PHP. Server overload?
- Can’t get wp_insert_post to work
- WSoD being caused by this piece of code
- I want to select the from values from database in WordPress? [closed]
- Update results, Before deleting the related category [closed]
- wp query foreach deleting record returning only first or last item
- Refresh table data with Ajax
- Database query works fine outside WordPress
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- $wpdb->insert() does not Insert record in a table
- Help with a $wpdb MySQL Query
- Custom array from a query only write the last row of the query
- $wpdb returns duplicate posts
- Mixing variables into an array when inserting values
- Use $wpdb or other PHP script method to find/replace in WP database
- How can I add a new row in a separate database when someone registers via WordPress?
- Basic wpdb update question
- I can’t update my data through $wpdb
- A $_POST should occur when submit form but is not?
- Output: “Array”
- How to use mysql LIKE with wpdb?
- Cannot access $wpdb, comes back NULL
- Submitting a form, using Ajax, to run a SQL Select query based on user input from the form
- How do I prepare strings for insertions as values into a MySQL table?
- Live search from database table
- Processing ajax call to php to insert into mysql database
- form $_post action value gets truncated after it passes through two forms
- Why won’t this wpdb get_results query return results?
- WPDB secure custom form
- Add row to custom database Table and delete all rows older than 1 day
- select a single val though a table in wordpress
- populate select options from extra mysql table data
- Query the links Database
- MySQL Query Returns Array () In Shortcode
- Using Ajax to submit a form, and run a SQL Select query based on user input from the form
- Passing in MySQL prepare statement parameter separately throwing error
- Convert a column of a table containing an Array as response in HTML
- Database SQL query error
- MYSQL TIMESTAMP when adding DATE_FORMAT then the output is blank, PHP conflict?
- Conditional formatting on data fetched from MYSQL
- What is the correct way to search 3 custom fields only in WordPress?
- Using wpdb to connect to a different database is not working
- autocomplete in wordpress using ajax with json-data
- Rewrite SQL query as a prepared statement and use in foreach loop
- Prepared DB Query from _POST array
- Advanced WordPress SQL Query
- Ajax not updating to database
- Passed variable gets undefined variable error on insert on next page
- Run insert if no entry otherwise run update with ajax
- MySQL queries in WordPress
- Using the same shortcode to show any table from the database
- AJAX with Selectbox Plugins (Select2, Chosen, Selectize)
- MySQL database migration to WordPress
- How to display inputted data in Ajax without button or click event
- WordPress Query -> Ajax Query
- how to display tables via ajax
- Error resetting database index using ALTER TABLE in $wpdb->query
- Putting form result in my database
- How can I update a value of a field depending on outside source?
- Trying to GET data with ajax from database and show in fullcalendar
- How to use update and delete query in wordpress
- How to implement WP_List_Table? WP_List_Table giving array instead of a value in listing table
- Show only one post for each author ( Page loads too slow )
- Would manually deleting the dumping data fix a “#1062 – Duplicate entry ‘1’ for key ‘PRIMARY'” phpMyAdmin error?
- WP database error for comments_popup_link()
- How to speed up admin-ajax.php in wordpress
- wp_insert_post() is returning the correct post ID, no failure, but the post content does not get updated
- Show success or error messages in Ajax response to WordPress custom registration form
- How to add a Custom Mailchimp AJAX Newsletter Subscribe Form
- Error using WordPress $wpdb object to get result from custom table
- How to retrieve the data from the sever and displaying it in a page?
- SOAP Request/Parsing XML From wp_send_json_success
- Errors being created by admin-ajax.php
- Ajaxurl suddenly not defined
- How to split AJAX response into two divs
- How to set variables with AJAX request to use in another function in WordPress
- WordPress mysql deos not work with php7
- Need help with AJAX login to call php in functions.php to handle redirects based on user cap (role)
- Ajax in a class instantiated via shortcode
- Add two or multiple functions in WordPress Post or Page
- How to set max users to 17.000
- WordPress will suddenly stop saving files uploaded by my code (ran in nopriv ajax)