The wpdb class, accessed via the $wpdb global variable, is used to interact with the WordPress database

learn more… | top users | synonyms

0
votes
0answers
18 views

Fetching array of postmeta with $wpdb and in_array conditional

I'm trying to fetch an array of all entries to a specific meta key and then check to see if the user input value exists in that array. I've checked the data base for the query and I see the meta ...
-2
votes
0answers
41 views

Already has more than 'max_user_connections' active connections wp-db.php

ERROR : mysql_connect() [function.mysql-connect]: User already has more than 'max_user_connections' active connections in /nfs/c09/h01/mnt/12345/domains/domain_name/html/wp-includes/wp-db.php on ...
0
votes
0answers
6 views

Custom table in my plugin print UTF-8 (מוברש) charsets and not hebrew

i have created custom table in wordpress db to use my plugins needs. i have campaigns with hebrew names, this saved to column (varchar(100) utf8_unicode_ci ) in the DB i dont see hebrew but this: ...
0
votes
0answers
19 views

How to use ajax in wordpress plugin to get data from coustom DB?

i have created php script that work great as stand alone. now i need to create this script as wordpress plugin. so i have created custom table in wordpress DB. then i tried to make the ajax call. in ...
1
vote
2answers
23 views

wpdb custom post_type problem

I want to use custom post type in my custom SQL query, but, when I add the custom post type im my query, I get no results. Where's my probelm ? This is the code I've tried $top5_ov_performance = ...
0
votes
1answer
18 views

Order by in foreach

hello im getting post_id by using wpdb after that i wanna show postmeta(sd_l2) order by their value i uses this codes global $wpdb $top5_ov_performance = $wpdb->get_results("SELECT post_id FROM ...
0
votes
0answers
10 views

Unable to create custom table , register_activation_hook from class

Cannot create the table , what am i missing class em_db { public function em_events_custom_table() { global $wpdb; $table_name = $wpdb->prefix . "em_events_db"; ...
0
votes
0answers
14 views

run search / query from multiple databases

First of I would like to warn everyone, that my skills set in mysql and php is novice. My current wordpress website is based on a network setup (mutli-site), with the help of shardb, I was able to ...
0
votes
0answers
37 views

Storing PHP structure data in the wp_options table?

I searched too much about that but can't find resonable answer of that question I am creating a WordPress plugin that has so many options that I need to store so to store data using option API which ...
0
votes
0answers
23 views

Wordpress WP_Query post__in

I try to get value from database==> postmeta ==> Meta value : value Using this code $promo_value = $wpdb->get_results("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = '_product_id' ...
0
votes
2answers
24 views

Custom Wordpress Table wpdb

running into issues querying a custom table and getting results. As of Wordpress 3.9, I can no longer run mysql_query(), and have to use $wpdb->query(); So keeping that in mind: Old Code: <?php ...
0
votes
3answers
28 views

selecting row using wpdb which contain special symbols

I got a table with one of the column have special charaters. I inserted to the table as $sql=$wpdb->prepare( "INSERT INTO `mytable` ( `question`, `remarks`) VALUES ...
0
votes
0answers
36 views

Insert data to DB

I create plugin and that plugin, when is activate, create new table in DB.. Now i need to insert some data like (firstname, lastname..) in that table.. Here is my form : <form name="cool_form" ...
0
votes
0answers
27 views

$wpdb error : call to a member function insert() on a non-object

I'd like to add data to my custom wordpress table of my plugin, here is my code: <?php global $wpdb; $data = $_POST['name']; $wpdb->insert('ct_data' , array( 'name' => $data ), array( "%s" ...
0
votes
0answers
27 views

Get results from wordpress data custom table

Firstly i created a custom table into the wpdb : global $wpdb; $table_name = $wpdb->prefix . 'countdown_table'; $sql = ' `id` int(11) NOT NULL AUTO_INCREMENT, `styleName` varchar(255) ...
0
votes
0answers
28 views

Custom post type search shows “Not unique table/alias” error

If I search for a value on the page that shows the custom post type list ( edit.php?post_type=my_post_type ) then it returns normal results. But because I wanted to include the post meta fields in ...
0
votes
0answers
18 views

wordpress plugin admin area save settings

I am brand new in wp plugin development and i need your help cause throw web the answers that i find confused me. So i would like to make a countdown timer wp plugin for my website that will display ...
0
votes
1answer
33 views

How to fetch results from database

I'm attempting to customize a wordpress theme. I've added custom field cp_job with form submission. This indicates if the ad is either Buyer(Buying services) or Seller(selling services), which is now ...
0
votes
0answers
19 views

$wpdb->get_results in not an array

Using get_result I receive an "Invalid argument supplied for foreach()" because is not an array. I tried with get_col but I don't know how to extract the data and I don't know the difference between ...
0
votes
1answer
14 views

$wpdb variable throw this error Call to a member function get_results() on a non-object in

I've this error "Call to a member function get_results() on a non-object in" from this code: require_once($_SERVER['DOCUMENT_ROOT'] . $folder . '/wp-config.php'); ...
0
votes
0answers
48 views

Why are Wordpress e-mails full of “mysql_real_escape_string” errors? (wp-db.php)

Since recently all Wordpress e-mails, which include Woocommerce order confirmation emails, are full of errors like these: Warning: mysql_real_escape_string(): 19 is not a valid MySQL-Link resource in ...
0
votes
1answer
46 views

List of ways to access WordPress database?

I'm trying to get a complete understanding of how WordPress works with databases. I've read the documentation but I'm getting confused by all the different approaches available. So far my ...
0
votes
1answer
52 views

Retrieving posts by their date and category

I'm trying to create a plugin for displaying post titles and dates (which will be displayed as links to those posts) of a specific date range and category. So far I have managed to get to display the ...
3
votes
1answer
80 views

WP_Query to work with custom view

I have created a Database VIEW on wp_posts which selects its all columns and exposes an extra calculated columns (average). So my View is identical to wp_posts plus one column, which I want to use for ...
1
vote
1answer
43 views

$wpdb - do you have to use foreach even if there will always only be one result?

I have a $wpdb query that will always only return one result. This is a simplified version of it: $results = $wpdb->get_results ( "SELECT name FROM testTable WHERE id=1" ); Do I have to use ...
0
votes
1answer
29 views

Should I use an additional column in the DB?

I'm building a site for a client. They need a functionality where WordPress can tell if a logged in user has viewed a post in order that they might serve a notice or hide the original content. I ...
0
votes
1answer
23 views

Unknown column 'siteurl' in 'where clause' WPDB outside

I am trying to get Mysql values from outside wp. My code: define( 'BLOCK_LOAD', true ); require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-config.php' ); require_once( $_SERVER['DOCUMENT_ROOT'] . ...
3
votes
2answers
100 views

Differences between wpdb->get_results() and wpdb->query()

Who can explain me the differences between wpdb->get_results() and wpdb->query() in making generic queries to wordpress db?
0
votes
1answer
45 views

Inserting a MySQL record into a table with an array of field names and an array of values

I see this in the Codex: $wpdb->insert( $table, $data, $format ); I'm using this type of code and it works: $wpdb->query( $wpdb->prepare( "INSERT INTO `table` ...
0
votes
1answer
31 views

Incorrect Use of wpdb::prepare()

Not sure what I am doing wrong here. I did not write this code however I am receiving the following error in WordPress: The query argument of wpdb::prepare() must have a placeholder. This message ...
0
votes
0answers
91 views

Inserting data into custom tables

I am trying to create custom input tables to send data into custom tables on the wp database. I cannot get my script to do anything. The user will enter a type of liquor, like vodka or whiskey, ...
0
votes
2answers
55 views

WPDB Prepared Delete

I am attempting to delete a row from my DB.I am using inputs from the user and I need to be able to sanitize using the prepared statement. The query itself looks like - DELETE FROM ...
0
votes
2answers
58 views

Trying to Connect to different database

I want to get list of 5 recent posts from a subdomain (not multisite) to show on our main domain. Following is the code am trying to execute, but is giving the error - Invalid arguments supplied in ...
0
votes
1answer
20 views

Outputting query results

I am trying to make plugin, and i followed codex, i am not a OOP literate, hence i a blank. I tried to run this query $myrows = $wpdb->get_results( "SELECT question FROM wp_quiz" ); while i tried ...
0
votes
0answers
14 views

adding a log row log table, when the draft post publish

i wrote some codes, about wpdb update query. but update_post meta works fine but, wpdb update query doesn't. where am i wrong ? here is the code ; add_action('publish_post', ...
1
vote
1answer
227 views

MySQL LIKE not working

It seems MySQL's LIKE operator behaves like a = operator. The following MySQL query returns the expected result (1 entry): $meta_key = '_locality'; $meta_value = 'The Hague'; $post_ids = ...
0
votes
1answer
75 views

plugin ajax to external php file always return null

I am struggling with this error for a while now. The plugin inserts data to the table. Here's the code : File : plugin/_add.php require_once('../../../wp-load.php'); global $wpdb; $table_name = ...
0
votes
0answers
18 views

Output terms based on custom fields

This question is rather specific. In my custom posttype "sak", I have a taxonomy called "vvpl". This taxonomy has a custom field called "revision" because a term have copies based on how many ...
0
votes
2answers
100 views

Object method calling for global $wpdb in header.php

I am developing a Wordpress plugin in an object oriented way, and I would like to read data from the wordpress database using the global $wpdb variable. The global $wpdb variable is called from ...
0
votes
0answers
15 views

Separate Register Login

I plan to create a bespoke login and register feature on my WordPress Frontend. These users won't have access to the backend of WP. Just to a frontend area. Should i store the information submitted ...
0
votes
1answer
19 views

Update vs Insert logic but the last key is always inserted?

I have added a custom db table which looks like usermeta table, just storing some key - value pairs. But now i am stuck with the following logic a/ if key exist for a user use an update query else ...
0
votes
3answers
82 views

How to display a specific category using a custom Query?

Hi I want to display a specific category from a custom query in WordPress. My code works fine and it gets the latest 4 posts, but what I want now is to retrieve a specific category. My code is below ...
0
votes
2answers
34 views

$wpdb->get_var multiple queries in one database check

I am using the $wpdb->get_var php code to get the first name and last name on the records, in the wp_usermeta table... But because the field value is stored in the same cell, I don't know how to merge ...
0
votes
2answers
140 views

How To Get Some Data From WordPress Database Using WordPress $wpdb Query?

I am trying to get some data from WordPress database tables in a plugin. For that, I am using the below code... global $wpdb; $findID = $wpdb->get_var("SELECT ID FROM wp_posts WHERE post_name = ...
0
votes
2answers
310 views

Call to a member function get_results() on a non-object in wordpress plugin

I am using revolution slider plugin. I got above error while executing one of my front end form. This is my code in that file.. <?php class UniteDBRev{ private $wpdb; private $lastRowID; ...
0
votes
0answers
131 views

$wpdb->get_results(…) returns empty array despite correct query

As title implies, I cannot seem to get $wpdb->get_results to give results. Running the "raw" query is successful, but this seems to be failing for some strange unknown reason. global $wpdb; ...
0
votes
1answer
105 views

What is _transient_random_seed for?

This is a very short question. _transient_random_seed is in wp_options. What is it for?
0
votes
1answer
47 views

How can I retrieve data from alternate database using wpdb class?

I'm attempting to retrieve data from a separate WordPress installation on the same server. I'm able to use the wpdb class to successfully connect to the alternate database and get results, however, I ...
0
votes
1answer
32 views

How to avoid conflicts with db.php / $wpdb and other plugins that decide to use them?

Our plugin (VersionPress) needs to track database changes so that it can version-control them. We currently do this by creating db.php and overriding the $wpdb instance in it but it has an issue that ...
0
votes
0answers
21 views

Issue On WordPress multisite its create new table for each user

I am using WordPress for multisite all configuration are right, but it's create new table for each user like (wp_1_options, wp_2_options, wp_3_options etc for each table) it's a very big issue for me. ...