MySQL is an open-source, relational database management system.

learn more… | top users | synonyms

1
vote
1answer
460 views

Using GROUP CONCAT in my-sql query with wp_usermeta table

I have a query that is meant to return user details from Wordpress tables. It would be fine if I was just SELECTing column names that I want, but within Wordpress there is a usermeta table which has 2 ...
1
vote
4answers
385 views

Migration: Copying database content to a different server

I'm migrating our WordPress site from one server to another. I need some hint on how to deploy a database dump (which I have) from the original server to the new one. There is no phpmyadmin (at least ...
1
vote
0answers
295 views

WPDB is not working when trying to run a custom query [closed]

I'm developing a WordPress plugin, and have no other plugins installed. The logging function is as simple as function log($message){ global $wpdb; $message = $wpdb->escape($message); ...
1
vote
1answer
297 views

Wordpress Post # of # filtered by category slug

I want to show post #4/100 at the top for each post for which I'm using following code function updateNumbers() { /* numbering the published posts: preparation: create an array with the ID in ...
1
vote
1answer
707 views

Call to undefined function get_user_meta() - trying to access data in MySQL from custom fields

I am trying to access data from some custom fileds in my MySQL db so that I can add them to a webpage that will be printed out. The data is held in a column called "paypal_user" and I need to access ...
1
vote
3answers
484 views

My WordPress site always displays a cached version of its homepage

First of all, sorry if I'm making a mistake. I already asked this on the ServerFault forum, but got no answers at the moment and I thought it would be a good idea to ask the question here, considering ...
1
vote
1answer
300 views

WP-DownloadManager - Query most download per week/month etc

I'm using this plugin (http://wordpress.org/extend/plugins/wp-downloadmanager/) as my download manager. While it's very simplistic and does great for what i need, the statistics to output on the site ...
0
votes
3answers
1k views

query to create woocommerce products from images

I have hundreds of art images in my WP media library, each of which I want to convert into a woocommerce product, and set as featured image of that product. Rather than manually adding new products ...
0
votes
2answers
7k views

Using Dynamic Data Pulled from a MySQL Table in a WordPress Page

I'd like to pull data from a mySQL database and put it in some tables in a WP page. I'm using WP 3.1.1. Imagine that I've got a table of sales figures that I want to pull from a mySQL database and ...
0
votes
3answers
722 views

Code to remove authors with no posts connected to them

I am looking for SQL code that I can run from phpmyadmin to remove all registered users on the blog that do not have any post associated with them.
0
votes
1answer
208 views

Order posts alphabetically: how to set order=asc in mysql query?

I have this function: global $wpdb; // adjust the query to fit your needs $posts = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_type = 'post' ...
0
votes
2answers
97 views

Copyright: Get first and last date of post type

I was searching for the easiest/fastest way to get the accurate date range for copyright notices in the footer. The copyright notice shouldn't only contain the year, but as well take month and day ...
0
votes
1answer
69 views

Migrating database / content of non-CMS site to Wordpress

I have a non-CMS website which is fully build with PHP with a lot of content in it. I don't want to add my posts manually in Wordpress, because that's a pain in the ass (I am talking about 5000 ...
0
votes
2answers
1k views

How to Query Database for posts with certain Taxonomy Term

I want to write a select query to return data on only posts which have are associated with the taxonomy term food-and-beverage SELECT wp_postmeta . * , wp_posts.post_name FROM wp_posts, wp_postmeta, ...
0
votes
1answer
652 views

mySQL query. ORDER BY meta_key

I'm fighting this quite long already and start to think I'm missing something big. CPT posts could have or not metadata ( _vip_post [0|1], _thumbnail_id [null|numeric] ). If i query for ...
0
votes
1answer
147 views

How i can obtain all the post meta for a specific post as an array?

<?php $fields = get_post_custom($ID); ?> This will fetch the custom fields ($key => $value) for $ID in to the array $fields. I want ALL the fields (both custom & standard WP fields) ...
0
votes
2answers
698 views

Help!! I Screwed up my WP

I was trying to clear up some empty tables left behind by other previously used plugins. As such i was trying to delete the GD Star rating plugin and now I cannot access my WP admin. i get the 'You do ...
0
votes
2answers
133 views

Can Categories be used to hack a Multisite-like setup w/ a single MySql db?

I have a project which will effectively create multiple blogs that will be fed existing content (don't worry, this isn't copyrighted content from other blogs or anything like that). From a DB ...
0
votes
2answers
4k views

Scanning Database for malicious Data

After a site of a friend has been hacked I told him he should just clean up the mess and restart from scratch so he know that no file has been altered. I could scan the site for him with tools like ...
0
votes
1answer
119 views

What do these phpMyAdmin errors mean on my WordPress databaes?

I'm getting 3 very similar phpMyAdmin errors on one of my WordPress databases. More than one INDEX key was created for column `comment_approved` More than one FULLTEXT key was created for column ...
0
votes
2answers
85 views

How to return number of found rows from SELECT query

I wrote a function which is supposed to return the number of rows found in a SELECT query but it always either seems to return 0 or an array. I have been messing around with this for about an hour now ...
0
votes
1answer
179 views

after wordpress update to 3.5+ i get many errors in plugin wpdb::prepare()

after wordpress update to 3.5+ i get many errors in this plugin. i found that the reason is: http://make.wordpress.org/core/2012/12/12/php-warning-missing-argument-2-for-wpdb-prepare/ I do not ...
0
votes
1answer
103 views

SQL Query in WordPress - Getting Impossible WHERE error

I don't get any result in the SQL query below. I am trying to find user_id of users with custom usermeta fields. SELECT DISTINCT user_id FROM wp_usermeta WHERE ( ( ...
0
votes
1answer
94 views

Create a WordPress administrator without access to back-end

My site recently got hacked, and all my admin users lost their administrator level access. But when I access mySQL database, I saw all the users still exist. How can I create an administrator when I ...
0
votes
1answer
415 views

Defining the same price to all WooCommerce Products

All of my products on my site are $1 and during an import I did using WooCommerce import it didn't save all the _regular_price & _sale_price values, so there is no way for the user to buy that ...
0
votes
1answer
354 views

SQL query not working in alphabetical post title/content search

I have an ajax request using wp_ajax sending one variable named "q" what I want to do is after the script get's the request to look inside the db and fetch the title and id of the corresponding posts ...
0
votes
2answers
70 views

Problem with admin login after deployment

I made a site for a friend and everything worked so far on my development box that we can start final deployment and testing so I decided to put it on the hosting. So I done the standard procedure ...
0
votes
2answers
2k views

Query to delete all featured images and remove post meta?

I'd like to run an SQL query to find all featured images from posts and delete the file itself and any references to it. Can anyone tell me how to accomplish this? Many thanks!
0
votes
1answer
258 views

Find out how many times the user has logged in

I'd like to determine how many times a user has logged in. Does WordPress retain that information or will I have to add a db entry every time they log-in? if(is_user_logged_in() && ...
0
votes
1answer
408 views

Speeding SQL queries for a large database?

I am using a WordPress plugin called feedwordpress in order to run a planet like website on wordpress (See it here). The plugin is great except for one thing - it hogs down my (VPS) server into ...
0
votes
2answers
693 views

Configure Wordpress to connect to Mysql DB using SSH tunneling

Problem: Configure wordpress to use a remote mysql database only available using and SSH tunneling. Stage: I have a wordpress instance over an apache server on machine (called WP_server). WP_server, ...
0
votes
1answer
5k views

Should I use wpdb prepare?

I'm new to SQL and am wondering if I need to use wpdb->prepare for the following query to a table I've created global $wpdb; $tablename = $wpdb->prefix . "my_custom_table"; $sql = "SELECT * ...
0
votes
3answers
744 views

How to find if a post with custom_field == X exists?

I need to find if a post with a custom field X equal to Y exists in a wordpress installation. Should I do it with a simple sql query or is there something build in that can help me achieve it?
0
votes
2answers
646 views

Have working sql query… trying to adjust it to use $wpdb

So I have this code that queries a custom plugin generated table in the wp database. It works perfectly as is. But I'm trying to adjust it to use $wpdb instead of the $con function I have set up. ...
0
votes
1answer
1k views

How can I SQL update a meta_value to remove the dollar signs that were entered with the value? (so just the value remains)

For all the "price" custom fields of a site, the dollar sign was entered with the value. I need to remove the dollar sign and leave the just the values. I know very little about SQL queries. The ...
0
votes
1answer
896 views

query users by role

I have a custom plugin which queries users and usermeta, but I now need to filter admins out of the results. A very simplified version of my sql query is: SELECT * FROM usermeta LEFT JOIN users ON ...
0
votes
2answers
899 views

Wordpress(wpdb class) and mysql stored procedures

$query = "CALL .........."; $result = $wpdb->get_results($query); print_r($results); Is returning an empty array and $wpdb->query does not return anything, how do you run stored procedures from ...
0
votes
2answers
72 views

Different database query in function.php using mysqli

I am trying to connect to a database in the function.php using mysqli. The code seems to run fine when it is not on a separate php file not on wordpress. But when I run it on wordpress I get "Connect ...
0
votes
1answer
55 views

Updating User Meta with SQL Query

I have a Wordpress site that needed to have 9,000+ users imported to set up a Directory Listing. I imported them from an existing MySQL (non-wordpress) database and everything imported just fine. ...
0
votes
4answers
93 views

Strange wordpress slowness

I read a lot about my problem. I have 4 years old Wordpress (with newest 3.8.1 Wordpress) site. And last months it become really slow. It takes about 3-5seconds to render page. In administration area ...
0
votes
1answer
53 views

How to stop $wpdb from prepending database name

When I run an UPDATE query using $wpdb, WP prepends the database name associated with the WP installation to whatever is passed in the table name argument. This isn't desirable as my app passes the ...
0
votes
1answer
88 views

Is altering a default WordPress database table update safe?

I want to add some table columns to the wp_terms table. Is it safe to use the dbDelta function with a modified CREATE-MySQL query for this? Or will I run into problems in the long turn? Is it update ...
0
votes
1answer
160 views

Query multiple tables at once?

I want to query all of the posts in my WordPress multi-site set-up looking for a certain string. This is only being done in Sequel Pro (on the command line) for my own inquisitive purposes but there ...
0
votes
2answers
39 views

Mixing variables into an array when inserting values

I have a function that inserts a load of values into a database. Not a problem but I have a condition that changes the mysql statement. The problem is is the way wordpress constructs the statement, ...
0
votes
2answers
166 views

update image path with words starting uppercase to lowercase chars

I have to convert the image path to lowercase characters inside wp_posts table. Right now, I have inside my posts this: <img class="alignleft" title="my image title" alt="my image alt" ...
0
votes
1answer
55 views

Should I use Wordpress to skin a database website?

I am going to start programming a website which allows users to post adverts for aircraft for sale. (Think autotrader for planes). It will be free to use. There are a few websites that do this already ...
0
votes
1answer
99 views

php include not working in custom page

The Problem I have a db.php file which contains mysql login details. I want it in a separate file like this so it can be linked in several different pages for easier tracing later. This all works ...
0
votes
1answer
87 views

How do I display offsite database info on my wordpress site?

I host some online games from my personal computer which the game saves information to my Mysql database. I would like to display live data (if possible) on my hosted Wordpress site. I know the ...
0
votes
1answer
97 views

Best practice to limit results in get_row()?

This is my query to check if a title exists (it's in a loop, therefore [$i]). $wpdb->get_row("SELECT * FROM wp_posts WHERE post_title = '" . $titles_arr[$i] . "'", 'ARRAY_A'); Anyway, I would ...
0
votes
1answer
149 views

Creating Database Table vs. Adding MetaData to Post & User

I am creating some event functionality for my wordpress site. Each event will have a set of tickets associated with it. A user who is purchased at least one ticket will additionally have a set of ...