wpdb->insert not working
EDIT: Rewrote the page from scratch and have been unable to figure out the differences. The new page works as expected. Checked multiple questions here and also on WordPress.org with no luck yet. Below...
View ArticleUsing “->” in a page to exceute $wpdb query gives error
I am doing some SQL queries in a WordPress page using the Insert PHP plugin, but the -> object operator changes to -> when I write code in the Text editor, or view in the Visual editor. When...
View Article$wpdb-prepare : Do I have to bind a parameter to the table name?
I only do a SELECT on a whole table – and the table is defined in a variable: $table = $wpdb->prefix . 'members'; Do I have to bind a parameter to this variable? This caused an error: $result =...
View ArticleCustom query: Get all posts that are from a certain category?
This is what I have: global $wpdb, $month; $months = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' AND DATE_FORMAT( post_date_gmt, '%Y' ) =...
View ArticleUnique user tables between three sites with same database
I have three websites that have their own prefixes, but are in the same database and have each member, and I have create a system that would allow to confine all its members in a mime table, so to...
View ArticleWhy is an empty result an error? ( $wpdb->get_row )
I have a query where I get the highest id from a table. $user_id = $wpdb->get_row("SELECT * FROM $table WHERE id=(SELECT MAX(id) FROM $table)") The table should always have rows, but if for some...
View ArticleGeographical proximity query using post_meta
I realise this might be an inefficient query, but I’m trying to grab latitude and longitude values from the post_meta table that are connected to posts to figure out the proximity of the posts to a...
View ArticleProper usage of $wpdb->update()?
I am trying to update my custom table in WordPress using the following php code but still no success: $tablename = "wpfeedback"; $data = array( 'mark' => $mark, 'comment' => $feedback_comment );...
View ArticleGetting id of poll from WP database
So I have a php statement: $latest_pollsid that contains a number which increases by 1 every time a specific form is submitted. I am reading this statement into several functions and for one of these...
View Articlewpdb get_results() returns only 2 rows
I am trying to create custom admin widget to present how many users has registered within last days. I have created function as below: function mdbootstrap_add_dashboard_recent_users(){ global $wpdb;...
View Article$wpdb to insert html form information
I’m trying to insert posted variables from a form. When I shorten the amount of variables I’m inserting it will sometime pass the information in my mysql database. Once I continue to add on information...
View ArticleWPDB – Read and write value from / to database
I have a custom field in usermeta called vatnumber. If the field has a value, how do I read that specific value for user X? Here’s what I have so far: <tr class="vatnumber"> <th><?php...
View ArticleProcessing a lot of $wpdb isn't insert all the data
In my plugin the user provides some CSV files that are processed and either inserted or updated based on a sku (which acts as a foreign key to my DB and a primary key for where the CSV comes from). I...
View ArticleCustom Query – Based on user input
I’m working on displaying suggestions to an input, assisting the user. I’m using the included jQuery suggest. That’s loading – and through ajax I’m using a custom SQL query and can see it’s attempting...
View ArticleDoes WordPress $wpdb functions wait when table is locked?
Does WordPress’ $wpdb functions wait when the table is locked? For example Function A() uses $wpdb->getresults. When $wpdb->getresults wants to read a table and its locked, does it wait for...
View ArticleWPDB Multiple site's posts and get featured images
I am using the code below to query 5 WordPress sites for their posts, merging them into an array, sorting the array by date, and then displaying them: //SITE 1 $mydb = new...
View ArticleInclude post_status check within $wpdb query
I’ve got a function that returns a count from the database for publish posts that match the product ID to the post meta ID (both are the product type). I’ve realized this query returns unpublished...
View Articlewpdb get_row database query inquiry
Is this the right way to use get_row with a select *? $_crds = $wpdb->get_row($wpdb->prepare(" SELECT * FROM `mailers` WHERE `id` = %d", $_GET['caId'] )); $_zipcodes = $_crds->zipcodes;...
View ArticleWordPress wpdb->insert returns int(0) => doesn't insert anything, no errors!
I am really clueless. I want to do an insertion in my WordPress plugin the problem is it doesn’t return any errors nor it insert the stuff! I don’t know how to fix this and really need your help. In...
View ArticleGet users within a latitude / longitude radius, based on custom fields
I’ve create two custom fields for my users: latitude longitude Here’s my code. I think I’m close: $user_query = $wpdb->get_results( " SELECT u.ID, u.user_login, latitude.meta_value,...
View Article