WordPress.org

Ready to get started?Download WordPress

Forums

MySQL Query not working... (3 posts)

  1. mrdthomas
    Member
    Posted 5 years ago #

    I have successfully inserted data into a custom table using the method in the Function Reference but now I am having a problem retrieving the data and displaying it in a template page.

    Here is the code that I used.

    <?php
    $x =  $wpdb->get_results("SELECT * FROM $wpdb->custom_table");
    
    foreach ($x as $y) {
    echo $y;
    }
    $wpdb->show_errors();
    ?>

    I get no results from this query just a blank page... Am I doing something wrong?

    Thanks.

  2. esmi
    Forum Moderator
    Posted 5 years ago #

    Have you tried just using:

    $x = $wpdb->get_results("SELECT * FROM custom_table");

  3. mrdthomas
    Member
    Posted 5 years ago #

    I tried that and I get

    Catchable fatal error: Object of class stdClass could not be converted to string in /path/to/file on line 50

    Any other ideas?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.