Title: adviceit's Replies | WordPress.org

---

# adviceit

  [  ](https://wordpress.org/support/users/adviceit/)

 *   [Profile](https://wordpress.org/support/users/adviceit/)
 *   [Topics Started](https://wordpress.org/support/users/adviceit/topics/)
 *   [Replies Created](https://wordpress.org/support/users/adviceit/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/adviceit/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/adviceit/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/adviceit/engagements/)
 *   [Favorites](https://wordpress.org/support/users/adviceit/favorites/)

 Search replies:

## Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[SportsPress - Sports Club & League Manager] Problem with Event Importer](https://wordpress.org/support/topic/problem-with-event-importer/)
 *  Thread Starter [adviceit](https://wordpress.org/support/users/adviceit/)
 * (@adviceit)
 * [11 years, 12 months ago](https://wordpress.org/support/topic/problem-with-event-importer/#post-4933983)
 * I’ll give that a go, them example CSV from the plugin the date format is:
 * `mm/dd/yyyy`
 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [Retrieve Live Data from wpdb](https://wordpress.org/support/topic/retrieve-live-data-from-wpdb/)
 *  Thread Starter [adviceit](https://wordpress.org/support/users/adviceit/)
 * (@adviceit)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/retrieve-live-data-from-wpdb/#post-4204332)
 * ok sorted the 500 error was wrong reference to the wp-load.php not referencing
   he right location.
 * some : “../” needed.
 * Incase anyone else finds this post here are my scripts:
 * AJAX call in javascript:
 *     ```
       $.ajax({
       				cache: false,
       				url: "<?php bloginfo('template_url'); ?>/scripts/sales.php",
       				success:function(data) {
       					$("#sales-figure").html("<table><tr><td><br/><h2>Total for <?php echo date('F jS'); ?> is: </h2><H1 style='color:blue'>£"+data+"</h1></td><td id='sales-update-ticker'>Next Update: 1:00</td></tr></table>");
       				}
       			});
       ```
   
 * PHP file:
 *     ```
       <?php
       require_once('../../../../wp-load.php');
         global $wpdb;
   
        $results = $wpdb->get_var("SELECT SUM(NET_AMOUNT) FROM wp_dailysales");
        if($results == "")
        {
       	$results = 0;
        }
        echo $results
       ?>
       ```
   
 * Thank you for your assistance guys.
 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [Retrieve Live Data from wpdb](https://wordpress.org/support/topic/retrieve-live-data-from-wpdb/)
 *  Thread Starter [adviceit](https://wordpress.org/support/users/adviceit/)
 * (@adviceit)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/retrieve-live-data-from-wpdb/#post-4204331)
 * Hi
 * Ok, think i understand what you are saying. The page and the code is static, 
   so the variables will be also.
 * So if i perform a GET from a new php page which returns the result that will 
   work…
 * Ok cool, I have now added this to a new PHP page but keep getting Error 500 from
   the new PHP page, when i try and reference the $wpdb variable or its functions
   I get this error.
 *     ```
       <?php
       include ('wp-load.php');
         global $wpdb;
   
         $results = $wpdb->get_var($wpdb->prepare("SELECT SUM(NET_AMOUNT) FROM wp_dailysales")); 
   
         echo $results;
   
       ?>
       ```
   
 * I think it is because it doesn’t know what the object $wpdb is. So I tried all
   the includes I could think of without any joy.
 * Any ideas?
 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [Retrieve Live Data from wpdb](https://wordpress.org/support/topic/retrieve-live-data-from-wpdb/)
 *  Thread Starter [adviceit](https://wordpress.org/support/users/adviceit/)
 * (@adviceit)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/retrieve-live-data-from-wpdb/#post-4204311)
 * tried the resetdb() and this had the same result.
 * Thanks
 * Simon
 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [Retrieve Live Data from wpdb](https://wordpress.org/support/topic/retrieve-live-data-from-wpdb/)
 *  Thread Starter [adviceit](https://wordpress.org/support/users/adviceit/)
 * (@adviceit)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/retrieve-live-data-from-wpdb/#post-4204310)
 *     ```
       function getSales()
       		{
           		$(".updatingSales", this.DOM_obj).removeClass("hideMe");
       			<?php
       				global $wpdb, $total;
       				$wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
       				$sales = array();
       				$total = 0;
       				$sales = $wpdb->get_var($wpdb->prepare("SELECT SUM(NET_AMOUNT) FROM wp_dailysales"));
       			?>
   
       			$panel = document.getElementsByClassName("panel-6")[0];
       			$content = $panel.getElementsByTagName("span")[0];
       			$content.innerHTML = "";
       			$content.innerHTML = "<table><tr><td><br/><h2>Total for <?php echo date('F jS'); ?> is: </h2><H1 style='color:blue'>£<?php echo $sales ?></h1></td><td id='sales-update-ticker'>Next Update: 1:00</td></tr></table>";
       			updatemins = 0;
       			updatesecs = 59;
       			setTimeout(function(){$(".updatingSales", this.DOM_obj).addClass("hideMe")}, 500);
       			setTimeout(function(){getSales()}, 1*60*1000);
       			clearTimeout(salesticker);
       			salesticker = setTimeout(function(){updatesalesticker()}, 1000);
       		}
       ```
   
 * This is the complete function. it is self calling on the setTimeout after 1 minute.
 * Thanks
 * Simon
 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [Retrieve Live Data from wpdb](https://wordpress.org/support/topic/retrieve-live-data-from-wpdb/)
 *  Thread Starter [adviceit](https://wordpress.org/support/users/adviceit/)
 * (@adviceit)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/retrieve-live-data-from-wpdb/#post-4204274)
 * I have also tried
 *     ```
       $wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
       				$sales = array();
       				$total = 0;
       ```
   
 * To try and clear everything but still getting the old results.
 * Simon
 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [Retrieve Live Data from wpdb](https://wordpress.org/support/topic/retrieve-live-data-from-wpdb/)
 *  Thread Starter [adviceit](https://wordpress.org/support/users/adviceit/)
 * (@adviceit)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/retrieve-live-data-from-wpdb/#post-4204266)
 * Hi Guys,
 * bcworkz you are correct that is the problem i am having I have tried the `$wpdb-
   >flush();` as well but got same result returned.
 * I change the script to show what $sale->NET_AMOUNT was and it was still showing
   the old values after a manual change to the database. But if I refresh the page
   it shows the new value.
 * Wierd…

Viewing 7 replies - 1 through 7 (of 7 total)