WSoD being caused by this piece of code

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’ => $quanid ‘Price’ => $inputValue ‘user’ => $hf_username ), ); … Read more

Get updated query results on page after insert in database

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( ‘votes’, array( ‘votes’ => $votes, ‘competition’ => $competition, ‘uid’ => $uid ) ) == … Read more

WordPress with php5-fpm and nginx

Ah, my problem ended up stemming from an issue with php5-fpm. Essentially, there were php5-fpm services running that were “old” and thus when I tried to access mysql from the web, it wasn’t detected. But when I tried to access it via cli, it was detected. That narrowed it down to php5-fpm for me, and … Read more

Mysql SELECT posts

I resolved creating SQL query: SELECT posts.post_title, posts.post_content, trans.element_type, trans.language_code FROM wp_posts AS posts INNER JOIN wp_icl_translations AS trans ON posts.ID = trans.element_id INNER JOIN wp_postmeta AS meta ON posts.ID = meta.post_id WHERE trans.element_type=”post_product” AND trans.language_code=”de” This is added only if you need something on post_meta: … INNER JOIN wp_postmeta AS meta ON posts.ID = … Read more

What is a valid parent for get_terms()?

The only variable which can really have an effect on the result as you described, is taxonomy. If you have verified that there are terms with a parent of 1 and a parent of 5, and get_terms() only returns terms for terms with a parent of 1, it can only mean that term 1 and … Read more

Create WP_Query to search for posts by their categories or their parent/child categories

Use get_categories first to get all the post categories to use in the form, then loop through them to display a multicheck input… function hierarchical_category_inputs ($cat, $indent) { $cats = get_categories(‘hide_empty=false&orderby=name&order=ASC&parent=”.$cat); $indent++; if ($cats) { foreach ($cats as $cat) { echo “<input type=”checkbox’ name=”cat-“.$cat->term_id.”””; echo ” style=”margin-left: “.($indent*10).”px;”> “.$cat->name.”<br>”; hierarchical_category_inputs($cat->term_id, $indent); } } } echo … Read more

Accessing data from a non-WP database/table within a page content

<?php $mydb = new wpdb(‘uid’,’passwd’,’database’,’localhost’); $mydb->show_errors(); $query = “SELECT DATE_FORMAT(col1, ‘%d-%b’) AS Pdate, DATE_FORMAT(col1, ‘%Y’) AS Pyear, col2, col3, col4, col5 AS fname FROM table ORDER BY col1 DESC LIMIT 50”; $result = $mydb->get_results($query); echo $mydb->num_rows . ‘ in table ‘; ?>