3
votes
1answer
44 views

How to use mysql IN statement with wpdb update method?

I am using wpdb update method and wish to update records where the id is not found within multiple ids. So if I wanted to update records where each had an id of 1 I would do for example: ...
0
votes
1answer
39 views

$wpdb in php 5.5

I am helping a friend update their website and move it over to a new server. Their old server is running php 5.3.6-13 and the new site is running php 5.5. There is a custom plugin that uses $wpdb ...
0
votes
1answer
49 views

How to optimize multiple insert into wordpress database

I had main file with my plugin and the another file with sql command. In the second file I create two tables and write data to one of them. But I have problem with. In my private computer everything ...
-1
votes
2answers
63 views

Fixing plugin for wpdb::prepare

A previous developer created a plugin for a website I manage and everything seems to work okay, except I'm getting the error "Missing argument 2 for wpdb::prepare()". I understand that the arguments ...
0
votes
0answers
112 views

Wordpress plugin tables become corrupt

I have written a plugin that creates and uses 3 database tables. On rare occasion, all 3 database tables become corrupt but no other tables in the database exhibit similar conditions. It is pretty ...
1
vote
1answer
371 views

Error on inserting a form value to database

hi i have decided to store few values in a separate table, So i created it and now i used a form to store values but when i process that form i'm getting error Trying to get property of non-object and ...
1
vote
1answer
1k views

How to create database table, add data, update and delete using wpdb via plugins?

I am just starting out to create plugins with database. I know to create a custom database when activating the plugin. I just want to know whether we can create tables at the front end like adding the ...
1
vote
1answer
206 views

Correct way to perform non-cacheable DB query

Consider the code function getNow() { global $wpdb; $now = $wpdb->get_var("SELECT NOW()"); $wpdb->flush(); return $now; } I am using the above method to avoid caching ...
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
170 views

Plugin to create Posts and Forums then choose category and parent forum

I need to create a plugin for a customer that will help him create posts and forums and place them in a category and choose if it's a parent or a child forum. Just created a GitHub Repo for my files ...
0
votes
1answer
43 views

$wpdb->update Issue

Can anyone see what I have wrong here? $wpdb->update( $table, array( 'lat'=>$paper_lat, 'lon'=>$paper_lon ), array( 'id'=> $result=>id ...
0
votes
2answers
140 views

Really simple query giving error in SQL syntax

I'm sure this is a simple oversight but I cannot seem to narrow it down: global $wpdb; $tablename = $wpdb->prefix . "icrm_folders"; $sql = $wpdb->prepare( "SELECT * FROM %s", $tablename ); ...
0
votes
1answer
58 views

How to relate the Category to user?

I am developing one new plugin, In that i had a section to create new category, and having the field Created By(listing all the users in this field). I am storing the category name in WP_terms and ...
1
vote
2answers
2k views

How to insert data to a database table when the field is not yet created?

Supposing I have an existing table(already created in dB) that handles user-registration (a plugin) and insert data using the $wpdB->insert like this: $success = $wpdb->insert( ...
1
vote
1answer
42 views

Where to store the name of a custom table?

I'm extending the $wpdb object with properties for my custom tables. function setup_wpdb() { global $wpdb; // Create properties for custom tables $wpdb->my_plugin_table1 = ...
0
votes
1answer
59 views

Nothing happens on Wordpress Update command

I made a function in Wordpress, which should update one field status to 0. But no changes are made to the database. I don't know what is the reason. Can someone please help. I tried looking into ...
1
vote
1answer
112 views

Using WPDB to output raw XML fails because of wp-blog-header.php

I'm coding a plugin. One particular file of this plugin is supposed to pull data from the plugin's custom DB table, and output it with minimal processing as raw XML. The problem is, to get the WPDB ...
-2
votes
1answer
35 views

How to dispaly post informations (such as titles) in an admin plugin menu page?

I'm trying to develop a WP plugin to show post(or page) related information (such as show all post title in a list) in an admin menu page. I tried to use "The Loop", but it seems like "The Loop" ...
2
votes
1answer
610 views

dbDelta only creates the last table

I'm using following install function with dbDelta as referring to the codex, articles on SO I watched out for the typical problems with e.g. one space instead of two spaced at the PRIMARY KEY ... ...
3
votes
2answers
3k views

Retrieving custom fields with $wpdb->get_results

I'm trying to use $wpdb->get_results to retrieve an array of all posts including custom fields. I can retrieve the meta_key and meta_value columns like this: [meta_key] => state [meta_value] ...
0
votes
2answers
400 views

include wp-blog-header not working on MAMP

To clarify my question... My plugin is/was using AJAX to call the file pluginname/submit/pick.php My pluginname/pluginname.php contains the usual plugin header and wordpress automatically finds it. ...
1
vote
3answers
2k views

Help With MySQL to WPDB Query Conversion

I have a problem. I've got a PHP script that tracks individual file downloads, and I'm looking for a way to display that number in individual posts. I've got a half-baked solution- a plain ol' MySQL ...
0
votes
1answer
1k views

Wordpress database error: [Query was empty] - using $wpdb->prepare()

I have edited my question, I'm now getting the error about checking my MySQL settings. I changed the $sql_dvalues variable to an array with the values instead of comma spaced values and now it is ...
0
votes
3answers
5k views

wpdb->prepare and mysql UPDATE - how is it done?

Trying to set a 'removed' date time in a plugin query but I'm not sure how to use UPDATE SET with $wpdb->prepare. Here's my query: $cur_date = date('Y-m-d G:i:s'); $rows_affected = ...
0
votes
1answer
94 views

Why doesn't my Table get created?

I am working on creating a table in the DB for a plugin but cannot figure out why the table is not being created. Here's my code: global $ds_swoons_db_version; $ds_swoons_db_version = '1.0'; ...
3
votes
1answer
6k 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 * ...
2
votes
3answers
766 views

Using $wpdb object in a widget

I'm trying to make a very simple widget that access tables contained within the same database instance as my Wordpress database, but are not wordpress tables. I'm using the wpdb class according to the ...
3
votes
2answers
975 views

$wpdb->insert is changing a value

I'm writing a plugin called 'Featured Releases' for a client. The user fills out a short form in the admin area which inserts some text and an image id into the wordpress database via $wpdb->insert. ...
2
votes
1answer
4k views

Check for success of $wpdb->update() correctly

My code is if( $wpdb->update($tableName,array('opt_value'=>$cInfo),array('opt_name'=>'showWeatherWidget'))) //show success message else // show failure message This is not ...