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>’; }

Insert NULL value using prepare()

the quick solution I found is to str_replace empty value. /* Query */ global $wpdb; $tablename = $wpdb->prefix . ‘data’; $sql = $wpdb->prepare( ” UPDATE $tablename SET `date` = %s, WHERE id= %d “, $_POST[‘date’], $_POST[‘id’] ); // SQL = UPDATE prefix_data SET `date` = ” WHERE id = 1 $sql = str_replace(“””,’NULL’, $sql); // … Read more

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