Ajax $wpdb not returning table data

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. … Read more

Using $wpdb->update but confused on the WHERE in and SET

You need to look at the documentation for the function, which is available here. The function takes the following arguments: $table The table name. $data A PHP array where the keys are the columns and the values are the the values to be inserted into those columns. $where A PHP array where the key is … Read more

Strange string in console from wpdb query

That is a placeholder escape string generated by wpdb::placeholder_escape() which is used by wpdb::add_placeholder_escape() and which is called by wpdb::prepare(). So it is safe to keep those escape strings, but there is a wpdb method for removing them: wpdb::remove_placeholder_escape(): // In your case, you’d use $this->wpdb in place of $wpdb. $query = $wpdb->add_placeholder_escape( ‘LIKE %night%’ … Read more

Join new table with SQL query

Always escape/prepare your data Don’t leave it open to injections: global $wpdb; $all_posts = $wpdb->get_results( $wpdb->prepare( ” SELECT %s.* FROM %s LEFT JOIN %s ON(%s = %s) WHERE %s=”soundcloud” AND %s=”%s” ” ,$wpdb->posts ,$wpdb->posts ,”{$wpdb->prefix}soundcloud” ,$wpdb->posts.ID ,”{$wpdb->prefix}soundcloud.idpost” ,$wpdb->posts.post_type ,$wpdb->posts.post_name ,$name ), OBJECT ); echo ‘<pre>’.var_export( $all_posts, true ).'</pre>’; Use the prefix $wpdb; offers the $wpdb->prefix, … Read more

Using WPDB class

You can’t mix wpdb with mysql_fetch_array. They are not compatible. You need to use wpdb methods, plus PHP functions like while, foreach, and for. wpdb does not return the references that PHP’s mysql functions use. It returns an object, and array, or sometimes a string. In your case, though, the database part is done. You … Read more

Doing a loop with multiple DBs simultaneoulsy

In the name of bad practices, I’m going to advise that you immediately rule out these using raw SQL queries with remote databases in the same page. It would be slow, insecure, and a hassle to maintain. That you’ve landed yourself in a predicament where a combination of hyperDB+multisite is not an option demonstrates that … Read more

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