The tag has no wiki summary.

learn more… | top users | synonyms

-1
votes
2answers
36 views

What's wrong with my $wpdb prepare

I can't get my head around this. I get this error: Parse error: syntax error, unexpected '"' in 224. The line is this between foreach $html: $html = ''; foreach ( $recent_across_network as $post ...
0
votes
1answer
23 views

Missing argument 2 for wpdb::prepare() Issue

I'm having to update a WP installation for a community organisations from version 2.9.1 to the current 3.9.1. The installation has a couple of custom built plugins that arent documented. Ive just ...
0
votes
1answer
83 views

Prepared statements used incorrectly in ACF?

I've just updated to WP 3.9 and it returns a warning when using placeholders incorrectly. I've found some prepared statements written incorrectly, but I really got worried when I saw this in the ...
2
votes
1answer
132 views

Is $wpdb->prepare escaping to much? How to use it properly?

Im pretty much confused by $wpdb->prepare. I want to use it to sanitize user input but it turned out that it destroys the query. I cannot imagine that this is how it's intended to work but I can't ...
0
votes
1answer
140 views

Use wpdb->prepare for `order by` column name

In my current plugin, I am picking up the order by column as user input. So I thought of using wpdb->prepare to escape it. $wpdb->get_results($wpdb->prepare("Select id from $wpdb->posts ...
1
vote
2answers
41 views

How to use IN array properly in Wordpress?

I have an array containting these values (including the apostrohpes): 'course_3202','course_3201','course_3200','course_3199' I try to fetch results from these values in postmeta-table. SELECT * ...
0
votes
2answers
65 views

wpdb prepare: passing varible number of fields as second argument

As i want to manage the NULL fields in my db and wordpress functions doesn't allow to do so, i will need to dynamically generate a query depending on the situation. The problem is that i don't know ...
0
votes
0answers
10 views

WPDB preparing delete from [duplicate]

I know my variables and functions are ok, it must be the way I have added the prepare that is stopping it working. function delete_record($table, $id) { //deletes a specific record global $wpdb; ...
0
votes
1answer
85 views

Are term_taxonomy_id and term_id the same?

I have a custom query where I need a JOIN because I want to COUNT all the posts of a specific category. So I checked the tables and I found out that table wp_term_relationships contains a reference ...
0
votes
1answer
221 views

mysql update user's password and activation key

Instead of using the Default WP reset password form, I'm creating my own and I'm stumped on this prepared statement. I'm trying to update the user's password by checking their user_login and ...
1
vote
1answer
524 views

wpdb prepare syntax

$arr = []; array_push( $arr, 'wp_table', 1, '2013-12-24', 3, 'NULL'); $sql_prepare = "INSERT INTO %s (id, datea, one, two) VALUES (%d, %s, %d, %s) ON DUPLICATE KEY UPDATE one = VALUES(one), two = ...
0
votes
1answer
75 views

Is it necessary to escape LIKE term in WP_User_Query?

While searching for partial string searches using WP_User_Query I came across this answer by @kaiser who has provided some great answers here on Stackexchange. However, I was confused over the use of ...
0
votes
1answer
82 views

wpdb_prepare with multiple or condition

I want to execute a query like this: $wpdb->prepare( "SELECT * ... from ... WHERE ( post_title LIKE '%%%s%%' or post_content LIKE '%%%s%%' )..., $string ); If I do the query with only one ...
0
votes
1answer
159 views

wpdb prepare sql problem

I have problem with wpdb prepare and sql query. If i run the query directly thru wpdb->get_results it's working fine. Here it is: $alabala_sql = $wpdb->prepare( " SELECT * FROM ...
4
votes
1answer
205 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 ...
4
votes
1answer
260 views

prepare() not working

When I do this: $transients = $wpdb->get_col( " SELECT option_name FROM $wpdb->options WHERE option_name LIKE '_transient_wb_tt_%' " ); It works ...
1
vote
2answers
704 views

wpdb->prepare function remove single quote for %s in SQL statment

I am using the below wpdb->prepare function in a sql statement. I am passing in several variables some field names and some values. When I try to use the %s for the field name it puts single quotes ...
1
vote
2answers
847 views

Can't pass table to $wpdb->prepare

I'm having trouble passing a table variable to $wpdb->prepare(); Here is functioning code: $table = $wpdb->get_blog_prefix( $blog_id ) . 'my_table'; $voters = ...
3
votes
2answers
2k views

Does $wpdb->prepare not create a prepared statement that I can execute multiple times?

I am wondering from the syntax $sql = $wpdb->prepare( 'query' [, value_parameter, value_parameter ... ] ) It appears (from the syntax - values within prepare) that it simple escapes values not ...
6
votes
2answers
2k views

What is the best way to sanitize data?

I've read several topics about this and different ppl have different views on the best practice. In terms of WP, how do I store data to DB the safest way? This is one insert I'm using now: ...