0
votes
1answer
88 views

wpdb::prepare was called incorrectly

I have this code to remove orphaned posts after deleting custom post type. It works, but this code... global $wpdb; $wpdb->query( $wpdb->prepare( "DELETE a,b,c FROM wp_posts a ...
1
vote
1answer
29 views

I want to select the from values from database in WordPress? [closed]

Here is my code: $sql = 'SELECT * FROM ' . $wpdb->base_prefix . 'item WHERE uname = "'. $_POST['login_name'] . '" '; $result = $wpdb->get_results($sql) or die(mysql_error()); foreach($result as ...
0
votes
0answers
48 views

Best way to execute custom page-specific mysql queries

I would like to query a secondary mysql database (not the Wordpress mysql database) with page-specific queries. I've seen many answers / tutorials on setting up a secondary mysql database, like: ...
0
votes
2answers
262 views

Inserting data into `post meta` table?

How would I be able to insert data into the post meta table? I know how querying and wpdb works but I have no idea how I can just insert it into the table. I have these two fields I want to insert ID ...
0
votes
2answers
105 views

Undefined variable: row?

I'm trying to select the post_title from wp_posts with a query which I did using this method: global $wpdb; $test = $wpdb->get_var( $wpdb->prepare(" SELECT post_title FROM ...
0
votes
0answers
44 views

Using the same shortcode to show any table from the database

I have a little question for you. I want to create a shortcode that makes a table with data that I have stored in a database. But i want to send the shortcode an attribute, to specify which table ...
0
votes
2answers
618 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
145 views

Add row to custom database Table and delete all rows older than 1 day

I'm editing a view counter plugin so that it logs the IP of every user that viewed a post. This is to prevent them from refreshing the page and thus creating artificial views. The part I'm having ...
0
votes
0answers
1k views

AJAX with Selectbox Plugins (Select2, Chosen, Selectize)

I have been searching all over the internet for tutorials on implementing AJAX actions from jQuery selectbox plugins such as Select2 , Selectize and Chosen. (these plugins look better than the inbuilt ...
0
votes
1answer
59 views

Get null from POST

I have problem with my code. I don't know why all my $_Post have null at the end.This is my code: function ow_display_user() { wp_enqueue_script('jquery-ui-datepicker'); ...
0
votes
1answer
41 views

Querying multiple meta_keys in Wordpress SQL query

Here's my Query... I'm looking to narrow this query down to users of one specific role ("meta_key = 'wp_capabilities' AND meta_value = 'employee'")...how do I add that additional conditional to this ...
1
vote
1answer
234 views

Creating a post from data returned from HTML form

I am trying to write a WordPress plugin and I have hit a bump. The Background: I have some data in a mySQL DB that I am using (each row has a unique ID and some other information I have added). I am ...
1
vote
0answers
347 views

$wpdb->insert() does not Insert record in a table

I'm trying to understand and get hold of the $wpdb global object but can't seem to make it work. Basically, I'm trying to insert a single record into a custom table in wordpress DB. Instead of ...
0
votes
1answer
471 views

Call to a member function get_row() on a non-object, Unable to use global $wbdp inside a plugin

I am building a custom plugin for my WordPress site. I made a php file called "checkrank" that obtains data from a custom table named "cranking". $uid = $GET['id']; function checkExists($id){ ...
0
votes
2answers
44 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
1answer
48 views

select a single val though a table in wordpress

The table is like this: category_id category_name category_parent_name I would like to get category_id by using category_name. I searched online, and the code is like below: $ad_cat is the ...
0
votes
1answer
74 views

MySQL database migration to WordPress

I have a MySQL database established for a web application I have been working on in a non WordPress database. This database has many tables with pre-populated rows for foreign keys etc. which took a ...
4
votes
1answer
189 views

Custom query to get post names beginning with a digit

I'm implementing an A-Z index for a custom post type. I've got my links printing out the page and the query working for the letters. However, the numbers are tripping me up because I don't want them ...
-1
votes
4answers
377 views

Insert into db with foreach problem

I have no idea why this foreach it`s not running. When i post the article, only inserts once. Should make it at much as needed. Do you see any problem? $array_produse = array(); for($i=1; $i<=8; ...
0
votes
1answer
332 views

Wordpress SQL JOIN query

Hi Im trying to run 2 querys in the same query call. // send the query global $wpdb; $commentQ = "SELECT * FROM $wpdb->comments " . $whereClause . $orderBy; $comments = ...
0
votes
1answer
264 views

Stackoverflow type of badge plugin giving warnings in Wordpress 3.5

I modified an abandoned Stackoverflow form of badge plugin to work with Wordpress 3.4.2 and it does indeed. The full script for it is here: http://pastebin.com/Ta91zXiL When upgrading to Wordpress ...
2
votes
2answers
129 views

queries inside of a class

I'm building a plugin and I'm quite new to wordpress I have a class what has couple of methods what should execute database queries. The class look as it follows class MyClass{ private ...
0
votes
1answer
335 views

populate select options from extra mysql table data

hi guys i am trying to populate a select element with options from the data in one of my sql tables heres what i have so far: <? $SQL = "SELECT * FROM pt_country ORDER BY name"; $rs = ...
5
votes
2answers
664 views

Can i use php sql functions instead of $wpdb?

I'm new to WordPress and was wondering why in WordPress API do they tell you to use functions such as prepare(), insert(), get_col(), get_row(), query(), etc. when technically I can use the built-in ...
0
votes
1answer
508 views

Query the links Database

Hi I'm trying to convert from a "example" wp_list_table that displays an array of data on the same page, to a "real life" table the pulls data from the database. I have the code setup to where I just ...
0
votes
2answers
280 views

Fetching review value using wpdb class

I'm generating an XML file using PHP for a website where they review tech products. In the XML file, I have to display the rating of products. For rating purposes, I'm using GD Star Rating plugin. ...
0
votes
1answer
492 views

$wpdb->flush(); breaks the loop

I am using $wpdb->flush(); at the base of my page in an attempt to prevent the query executing multiple times due to caching however it seems that it isn't flushing the most recent query but the ...
0
votes
1answer
703 views

Wpdb->insert() doesn't insert new row after the last one

In JavaScript, I'm using an Ajax call and I'm sending an array of shops. Except for the last element in the array all the shops already exist in the DB. The last element is a new shop. The PHP code ...
2
votes
1answer
2k views

Can't use get_results() in ajax query

I'm using a jquery ajax call to get certain data from wpdb and I'm getting the following message: <b>Fatal error</b>: Call to a member function get_results() on a non-object in ...
1
vote
2answers
760 views

Call External Object in Class Function During Callback

I've a class which has a function that check and creates table in database. In order to do so i need to use WordPress $wpdb object. I need the function to run only on first plugin activation, so i ...
0
votes
1answer
2k views

Fatal error: Call to a member function query() on a non-object

In the code below (from my functions.php), I'm attempting to create an array of items from the wp_postmeta table where the meta_key is "_wp_attached_file". I'm getting an error: Fatal error: Call to ...