WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Cant retrieve field value (8 posts)

  1. crashguru
    Member
    Posted 1 year ago #

    I need to retrieve and process the value of an input field ( AWPCP plugin).
    I looked up the field's name in the database: ad_item_price
    I put this code on my page ID6 ( with php plugin):

    [ Moderator note: it's the backtick character for code and not the single quote. Or use the code button, that works too. ]

    <?php
    global $post;
    $adbudget = get_post_meta(6, 'ad_item_price', true);
    print($adbudget);
    ?>

    to see whether I get the value, but no luck. What is wrong?
    Thank you very much in advance for any hints!

    PS I am an old hardware eng., not a php programmer...

  2. Andrew
    Forum Moderator
    Posted 1 year ago #

    Can you var_dump($adbudget); and see what that returns?

  3. PS I am an old hardware eng., not a php programmer...

    Well that got my interest. ;)

    Which plugin do you mean? This one?

    http://wordpress.org/extend/plugins/another-wordpress-classifieds-plugin/

    Knowing which one will make it easier to help you out.

  4. crashguru
    Member
    Posted 1 year ago #

    The var_damp returns bool(false) and yes, that is the plugin.

    Thank you for the quick reply gentlemen!
    Please stay with me... :)

  5. crashguru
    Member
    Posted 1 year ago #

    I made a mistake, var_dump($adbudget); returns string(0) ""

  6. crashguru
    Member
    Posted 1 year ago #

    The guy from the AWPCP plugin tries to hold back as much info from his paying customer as he can. At least I learned that the price data is not in a post or page.
    I found a query in one of their files re. the ad_item_price and wanted to try this code

    global $wpdb;
    $tbl_ads = $wpdb->prefix . "awpcp_ads";
    $my_result = $wpdb->get_var( "SELECT ad_item_price FROM ".$tbl_ads.");
    echo $my_result;

    , but it gives a parser error "unexpected end of file". I cant figure out what is wrong with it.

    Help please !

  7. crashguru
    Member
    Posted 1 year ago #

    This code appears to have the right syntax, but always returns 20000, no matter what the price is.
    global $wpdb;

    $tbl_ads = $wpdb->prefix . "awpcp_ads";
    $my_result = $wpdb->get_var( "SELECT ad_item_price FROM ".$tbl_ads);
    echo $my_result;

    I am running out of ideas ...

  8. crashguru
    Member
    Posted 1 year ago #

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic