wpdb replace returning 1 where delete and insert is expected

I have found here that; It is possible that in the case of a duplicate-key error, a storage engine may perform the REPLACE as an update rather than a delete plus insert, but the semantics are the same. Which would return 1 row affected on what should otherwise be a delete and insert. I am … Read more

og:image functions.php

Use var_dump($ogimage); to understand the contents of $ogimage presumably it’s returning an array of records from the database. Generally you would retrieve post meta values with get_post_meta WordPress Docs for get_post_meta() Also there are plugins that sort out the og tags for you such as Yoast SEO Yoast SEO plugin page on WordPress site

Check if Value Exists in Database, adding row details to variables and echoing result

Thanks @user141080 I had the table_name declared wrong. I also missing the ” around the ‘$postcode’, which you do by adding an extra ‘at the end of the where clause and .”‘” after the variable. The code below works now. <?php /*————————————————-*/ /*————-Check Postcode —————–*/ /*————————————————-*/ global $wpdb; $table_name = $wpdb->prefix.’vw_postcode_checker’; if (!empty($_POST[postcode])) { $postcode … Read more

Limit left join

You can’t use LIMIT directly with a DELETE query, it’s invalid syntax. I suggest you get the query working in a tool such as MySQL Workbench to ensure your syntax is correct first then you can migrate it to your WordPress code.

get_posts() SQL Injection

If not, how do I clean the incoming variables? In most cases you don’t, get_posts calls WP_Query internally, and WP_Query performs some sanitization, namely via wpdb->prepare. However, for what you’re trying to do, this is the wrong approach. Just use a standard search.php template with a standard post loop, and use input fields that have … Read more

Access to numerically indexed array in wpdb Class and undefined offset

var_dump($einzel); array(10) { [0]=> string(3) “144” [1]=> string(10) “21.05.2020” [2]=> string(10) “00.00.0000” [3]=> string(30) “Zugtag der Königsgilde Voitze” [4]=> string(14) ” ab 10.00 Uhr ” [5]=> string(0) “” [6]=> string(41) “Schützenhaus Voitze, Salzwedeler Straße” [7]=> string(6) “Voitze” [8]=> string(11) “Gaede,Joerg” [9]=> string(23) “[email protected]” } There are two same column names: ‘id’ and ‘name’. I worked … Read more

PHP | left join avg query give me Array()

You have a mistake in your query $sql = “SELECT {$wpdb->prefix}commentmeta.comment_id, avg({$wpdb->prefix}commentmeta.meta_value) avg_meta_value FROM {$wpdb->prefix}commentmeta LEFT JOIN {$wpdb->prefix}comments ON {$wpdb->prefix}commentmeta.comment_id = {$wpdb->prefix}comments.comment_ID WHERE {$wpdb->prefix}commentmeta.meta_key = ‘rating’ GROUP BY {$wpdb->prefix}commentmeta.comment_id ORDER BY avg_meta_value desc”; $results = $wpdb->get_results($sql); foreach ($results as $result) { echo $result->comment_id.'<br>’; }

SQL queries to another wordpress site

Putting an important credentials in functions.php is not a good idea. The better way is you can utilize WP REST API from your second site to handle GET and POST method for the data and using global $wpdb variable inside the code. You can either create a custom endpoint for that by making a custom … Read more

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