MySQL Query not working... (3 posts)

  1. mrdthomas
    Posted 6 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.

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

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


  2. esmi
    Forum Moderator
    Posted 6 years ago #

    Have you tried just using:

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

  3. mrdthomas
    Posted 6 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


No tags yet.