Support » Themes and Templates » MySQL Query not working…

  • 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?


Viewing 2 replies - 1 through 2 (of 2 total)
  • Have you tried just using:

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

    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?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘MySQL Query not working…’ is closed to new replies.