Printing an stdClass object

I have:

$value = $wpdb->get_row("SELECT custom_message FROM `wp_wpsc_cart_contents` WHERE purchaseid='" . $purchase_log['id'] . "'");

if I do:

Read More
print_r($value);

I get:

stdClass Object
(
    [custom_message] =>  |Castor Seed Oil  $4.45| 
)

So I tried to get that value doing:

foreach($value as $index => $result) {
   echo $result["custom_message"];
}

I also tried:

foreach($value as $index => $result) {
   echo $result->custom_message;
}

but that prints nothing, any idea what I’m doing wrong here?

Related posts

Leave a Reply

2 comments