Tag Info

New answers tagged

0

You can still do the AS with $wpdb, I find it still makes stuff look cleaner. You can use the $wpdb->prepare() method for sanitation. Are you looking for something like this? function combined_downloads($post_id) { global $wpdb; return $wpdb->get_var($wpdb->prepare( "SELECT SUM( meta_value ) FROM $wpdb->postmeta AS m LEFT JOIN ...


3

The insert method of $wpdb already scapes the data taking care of SQL injection. What you should worry about is about data sanitization and validation. For exmpla: Sanitization What type of data do you accept in $votes? A integer value? If so, be sure $votes contains a integer value. You cuold do it, for exmaple, using intval function from PHP. This is ...


2

wpdb::insert already protects against SQL injection, it's a wrapper for wpdb::prepare For insert(), you can pass a third "formats" argument for extra sanitization: $wpdb->insert( 'votes', array( 'votes' => $votes, 'competition' => $competition, 'uid' => $uid ), array( '%s', // $votes will ...


0

Move insert query to top of file. So it will select updated data. <?php // Save form data if(isset($_POST['submit'])){ global $wpdb; $votes = 1; $competition = $_POST['comp']; $uid = $_POST['id']; //$uid = get_current_user_id(); echo 'id of image = '.$_POST['id']; echo '<br>'.'competition is'.$_POST['comp']; if($wpdb->insert( ...


0

This is just bad security method. Because the only way you can connect to the mysql database is via that pc you use. Where is if you username/pwd, you can move the site to another server, etc. So Windows Authentication is a bad idea, too easy to overcome, and honestly just not that secure. Where as a username and strong password, that changes every so ...


1

Like your sample: $results = array( (object)array('id'=>1, ...


0

Outside of subqueries, MySQL will only process 1 query at a time. When running sql statements through phpmyadmin, it just executes 1 query after the other. To do the same thing in WordPress, it appears you just use 1 query per $wpdb object (those can have subqueries if desired, but not what's needed here).


0

Best Practice for WordPress, it also works when you change your host. downloadUrl("<?php echo get_template_directory_uri(); ?>/phpsqlajax_genxml3.php", function(data) {


-1

INSERT INTO wp_hgwrxz_posts ( post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_content_filtered, post_parent, guid, menu_order, post_type, post_mime_type, ...


0

There are a few ways you could do it- NOT IN, NOT EXISTS, IS NULL. Which method is best depends on your actual query. SELECT * FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = 'somekey' WHERE $wpdb->postmeta.post_id IS NULL


1

You have a problem with your code formatting and syntax at the very least: function ref_access(){ global $error; if (is_user_logged_in()) // <-- problem here... $newdb = new wpdb( 'user', 'pass', 'db', 'localhost' ); global $newdb; $hf_username = wp_get_current_user(); $inputValue = $_POST[$quanid]; $wpdb->insert( $table, array( 'ItemID' => ...


0

Import the database on the new server. When your domain name or URLs change there are additional concerns. The files and database can be moved, however references to the old domain name or location will remain in the database, and that can cause issues with links or theme display. If you do a search and replace on your entire database to change the URLs, ...



Top 50 recent answers are included