Reputation: 151
I am getting error while running following code
$value_sql = "SELECT test_fielf FROM `tbl_test` where `site_id`='".$sid."'";
$register_value = $db->fetchRow($value_sql);
echo $register_value;die();
The error : Catchable fatal error: Object of class stdClass could not be converted to string
Upvotes: 0
Views: 618
Reputation: 1239
Try this:
$value_sql = "SELECT test_fielf FROM `tbl_test` where `site_id`='" . $sid . "'";
$register_value = $value_sql -> fetchRow(DB_FETCHMODE_ASSOC);
print_r($register_value);
die();
Upvotes: -1
Reputation: 14263
you cannot use echo
for printing objects
$value_sql = "SELECT test_fielf FROM `tbl_test` where `site_id`='".$sid."'";
$register_value = $db->fetchRow($value_sql);
print_r( $register_value);
die();
Upvotes: 2
Reputation: 8767
Assuming the code you posted is as-is, you're missing a closing double-quote on the first line.
$value_sql = "SELECT test_fielf FROM `tbl_test` where `site_id`='".$sid."'";
$register_value = $db->fetchRow($get_register_value_sql);
echo $register_value;die();
The error you're experiencing is due to $register_value = $db->fetchRow($get_register_value_sql);
returning an object, not a string. If you wish to treat is as a string, then you can cast is as a string using:
$register_value = (string) $db->fetchRow($get_register_value_sql);
Upvotes: 1