I have used
$member_id = 12;
$results = db_query("select * from {customorders} where id = :fid", array(':fid' => $member_id));
foreach($results as $result) {
$name = $result['name'];
}
but I get error Fatal error: Cannot use object of type stdClass as array
so what could be solution , and please correct me if I have written wrong query for select
i want “select * from customorders where id = 12”
and customorders is my created custom table in Drupal database
Please help me..
Thanks
The
$resultvariable is returned as an array of objects. So you should use$result->nameinstead of$result['name'].Your code can be fixed to be like that:
Hope this works… Muhammad.