Using $wpdb generates DB error

its a syntax error according to error message. starements like below might work for you. global $wpdb; $wpdb->show_errors(); $tableCustom = ‘join_users_defis’; $sql = “SELECT * FROM {$wpdb->postmeta}”; $requeteAffichage = $wpdb->get_row( $sql ); //or $requeteAffichage = $wpdb->get_results( $sql ); var_dump($requeteAffichage);

Is there a (better) way to access $wpdb results?

This answer explains what the OP saw with column names and how to work with that, but the real answer is to use get_var() as in Howdy_McGee’s answer. The string you’re seeing is the column name that MySQL is using for the result, because it doesn’t have any better ideas. One way is to give … Read more

wpdb-> not adding prefix to custom table

$wpdb->tablename works only with the tables initially present in a WordPress installation. These tables are defined in wp-includes/wp-db.php. The second method you used is perfectly acceptable.

$wpdb->query() multiple query support

Using PHP 5.3.5, I was unable to make this syntax work even after setting the 5th parameter of mysql_connect() to 65536 (CLIENT_MULTI_STATEMENTS). Looks like it’s not possible to concatenate multiple queries into one statement as long as the old-school MySQL API is running the show. I assume you’re familiar with the MySQL multiple row INSERT … Read more

$wpdb is get_results escaped

The answer is: of course they are not – otherwise you couldn’t use them to save them in DB. But… the answer to your question isn’t so easy. Sanitizing is a process of preparing data for storing in DB. So for example if you insert some illegal characters in post_name, then it will be removed, … Read more

How Can I Use $wpdb in PayPal IPN file?

Use the ajax api: http://codex.wordpress.org/AJAX_in_Plugins If you let all your ajax calls go through this you will have access to all WP functions. Also take a look at these: http://www.james-vandyne.com/process-paypal-ipn-requests-through-wordpress/ http://wordpress.org/extend/plugins/paypal-framework/ Don’t know if what you want is in there, but worth a look.

What does wp_update_post() do that the $wpdb class does not?

wp_update_post() calls some hooks that $wpdb doesn’t on it’s own. You’ll have to do it on your own to make it compatible with other plugins. wp_update_post() calls some functions related to database entry sanitation, thumbnails, attachments, time (format, zone etc.), comment, taxonomy, meta, cache etc. So if you use $wpdb, make sure you handle all … Read more

WPDB->insert with special characters

If the same code works with add_option() and not with $wpdb->insert() in a custom table, it is probably because the collation of the custom table does not support the characters of the inserted data. It shoulud work if you set the collation of your table to UTF-8, utf8_general_ci at minimum (to allow support for emojis, … Read more

$wpdb prepared with search term

After a million tries I finally found it… $result = $wpdb->get_results($wpdb->prepare(“SELECT id, geslacht, voornaam, familienaam, email, tel, afile, app_datum FROM sollicitatie_form WHERE voornaam = %s”, $zoekvn)); I guess when you found the solution yourself you’re less likely to forget it 🙂

How do I create a single.php for a specific category?

I think this does what you want: function ag_templates( $template=”” ){ global $post; $meta = get_post_meta( $post->ID, ‘_category_permalink’, true ); if( 53 == $meta ){ $template = locate_template( array( “single-category-53.php”, $template ), false ); } return $template; } add_filter( ‘single_template’, ‘ag_templates’ );

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)