Updating with $qpdb->query() always returns 0 rows affected

wpdb uses PHP’s mysqli_affected_rows() or mysql_affected_rows(), which can be disabled via an argument in php.ini. I am guessing that that is what has happened. Check the disabled_functions line in your php.ini file and remove the references to those function. Of the top of my head, I am not sure if extensions like Suhosin mess with … Read more

wpdb query not returning results containing single quotes

Here is an example of performing a LIKE based query while escpaing the value parameter passed to the query: $results = $wpdb->get_results( $wpdb->prepare( “SELECT post_title, ID from $wpdb->posts WHERE post_title LIKE ‘%%%s%%'”, $wpdb->esc_like(“today’s weather is nice”) ) ); Update: Based on your edit, your query is incorrectly formed hence the error, it should be: global … Read more

Why is this $wpdb query looping 5 times?

The most likely cause is that the hook is probably running multiple times (e.g. once per meta field). You may need to qualify/filter your function like so… add_action( ‘added_post_meta’, function ( $mid, $object_id, $meta_key, $_meta_value) { global $wpdb; if ( $meta_key != ‘data19’ ) { return; } $table_name = $wpdb->prefix . ‘postmeta’; $results = $wpdb->get_var( … Read more

Custom select query two tables by a meta key

First of all you are trying to combine both of the tables by post_parent. $wpdb->posts.post_parent = $wpdb->ftcalendar_events.post_parent I guess data in the ftcalendar_events has children of posts table, try $wpdb->posts.ID = $wpdb->ftcalendar_events.post_parent Also you can try joining tables: SELECT * FROM $wpdb->posts JOIN $wpdb->ftcalendar_events ON $wpdb->posts.ID = $wpdb->ftcalendar_events.post_parent WHERE $wpdb->posts.post_status=”publish” AND $wpdb->posts.post_type=”post” ORDER BY $wpdb->posts.post_date … Read more

$wpdb->get_results breaking page?

For me the problem would be to use a plugin that uses evil() eval() to evaluate string as PHP, in the first place 😉 This part is from the PHP manual: Caution The eval() language construct is very dangerous because it allows execution of arbitrary PHP code. Its use thus is discouraged. If you have … Read more

Store plugin page content in wp_options?

Answering short: it’s legit and proper solution. Answering in details: 1. About the table capacity Considering _options table structure option_id | bigint(20) option_name | varchar(64) option_value | longtext autoload | varchar(20) and the fact that option_value (which is going to contain your HTML), is longtext – it can store L + 4 bytes, where L … Read more

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