Forums

Fatal error: Cannot use object of type stdClass as array in (2 posts)

  1. teemo
    Member
    Posted 1 year ago #

    Hi,

    I got this error message.
    'Fatal error: Cannot use object of type stdClass as array in'

    I create custom table in wordpress database.
    'wp_directory'

    and here is the code

    <?php
    $results = $wpdb->get_results( "SELECT id, name, address FROM wp_directory" );
    //echo "<pre>"; print_r($results); echo "</pre>";
    if ($results) {
      foreach ($results as $Row){
        echo $Row['id'];
        echo $Row['name'];
        echo $Row['address'];
      }  // foreach
    } // if $results
    ?>

    please help me.
    Thanks

  2. teemo
    Member
    Posted 1 year ago #

    oh I changed echo $Row['name']; to echo $Row->name;.
    it works now.

Topic Closed

This topic has been closed to new replies.

About this Topic