I have an error WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version

The problem here you are passing table name as a placeholder in prepare statement. Which is not allowed. You can directly add the table name in your query without quotes. Your query do not have any placeholder and arguments. So No need for prepare statement. Try following code. global $wpdb; $vragen = $wpdb->get_results( “SELECT * … Read more

How to redirect to a page after submitting form data?

Form handling needs to happen in functions.php (or equivalent) so that it triggers before headers are sent. Here is the how I achieved redirection after form submit: add_action(‘init’, ‘redirectAfterSubmit’); function redirectAfterSubmit() { if (isset($_POST[“submit”])) { insert_row(); wp_redirect( “/thank-you”, 301 ); die(); } } function insert_row(){ // form handing here }

Get count of rows based if column exists in two different tables

You need to use a join in your mysql query. Something like this might get you closer… global $wpdb; $rsvp_table = $wpdb->prefix . ‘rsvp’; $invites_table = $wpdb->prefix . ‘invites’; $sql=”SELECT COUNT(*) as count FROM $invites_table i1 JOIN $rsvp_table r1 ON (r1.reference = i1.reference)”; $yet_to_respond = $wpdb->get_results( $sql ); echo $yet_to_respond->count;

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)