Fatal error: Cannot use object of type stdClass Error help! When trying to access my image file from my database i get this error:


  Fatal error: Cannot use object of type stdClass as array in C:\wamp\www\drupal-7.25\sites\all\modules\database\database_ex.module on line 99


note: line 99 is $uri = $value['url'];

function database_ex_form_submission($uri) {
  $result = db_query("SELECT myimage FROM example");
  $records = $result-&gt;fetchAll();

  $res = $result-&gt;execute();

  foreach ($records as $value) {
    $uri = $value['url'];
    $url = file_create_url($uri);
  }
}


What seems to be the problem?
You say :


  note: line 99 is $uri = $value['url'];


So:

$value isn't an array and you can't write $value['url'];.

In fact $value is an object and you have to use this syntax $value-&gt;url;