WordPress.org

Ready to get started?Download WordPress

Forums

Why does my WPDB enquiry on test server work but not on the live server? (5 posts)

  1. mirefoot
    Member
    Posted 10 months ago #

    I am using wordpress to output some ads on a non wordpress page. The HTML on the non wordpress test server page is:

    <?php
        require('/home/mcreativ/public_html/parts/imagerotator/wp-load.php');
        echo init_ads();
        ?>

    On my Test server I have this code in the functions file and the post type is a custom post type I have created call manufacturer:

    function init_Ads() {
        echo $_SERVER['DOCUMENT_ROOT'];
    	$serial = $_GET["serial"];
    			// args for query
    			$args = array(
    				'numberposts' => -1,
    				'post_type' => 'manufacturer',
    				'meta_key' => 'smashing_post_class',
    				'meta_value' => $serial
    			);
        $the_query = new WP_Query( $args );
        $the_query->the_post();
        $meta= get_post_meta( get_the_ID(), 'ad_rotator_group', TRUE); 
    
        wp_reset_query();  // Restore global post data stomped by the_post().
    
    	echo adrotate_group($meta);
        }

    And on the test URL http://www.m1creative.org/noword/index.php?serial=57 it works.
    I am passing in a number 'serial' and extracting its corresponding ad group which then displays the correct ads on the page. Use serial = 57 to get a valid ad group.

    On the live server page: https://www.partslocator.com.au/adsrotator/testnoword.php?serial=57 it doesn't work.

    This is the HTML of the live server non wordpress page:

    <?php
        require('/var/www/plm/data/www/partslocator.vm-host.net/adsrotator/wp-load.php');
        echo init_ads();
        ?>

    If I change the echo adrotate_group($meta); to echo adrotate_group(1); I get the correct result and the ads display.

    I am not using the loop in the query as there is only ever going to be one result.

    Is the https causing me problems or is there something else I haven't spotted?

  2. mirefoot
    Member
    Posted 10 months ago #

    Any help would be much appreciated

  3. catacaustic
    very awesome
    Posted 10 months ago #

    If that's what's happening, then the value that's set for $meta is either different on the live server, or is set, but is set for a different post.

    This is where some basic debugging comes into it. You will need ot see what the value that you get for $meta is on both systems, and if it's not the same (I'm betting that it's not) work backwards through the code to see what else is different and where the differences come from. When you find that you should be able to answer your own problem.

  4. mirefoot
    Member
    Posted 10 months ago #

    Thanks, but $meta is NULL in the live site as far as I can tell, so no return is coming from WPDB

  5. catacaustic
    very awesome
    Posted 10 months ago #

    So... as I said before, work backwards and see what is happening to make it NULL instead of whatever value you epxect it to be.

    Start with this line:

    $meta= get_post_meta( get_the_ID(), 'ad_rotator_group', TRUE);

    Make sure the values going in there are the same.

    If they are, move backwards checking everything until you get to the start of your function. Something will be different. You just need to figure out what it is.

Reply

You must log in to post.

About this Topic

Tags