Have you confirmed that $result[0]->name
has a non-empty value (when you echo $result[0]->name;
)?
You might also do a var_dump( $result );
to see what your SQL query is returning an array of objects. Then make sure the first item in the array, $result[0]
, has a non-empty value for the property name
.