Trying to get property of non-object. Objects in php work on localhost but not on Hostingsite -
i have uploaded ci project on hosting site now, whenever script accesses property of objects, no longer recognized objects, therefore property can't accessed , used.
i've tried print_r($someobject)
, works fine. shows me properties.
when try print_r($someobject->property)
no longer works. message is:trying property of non-object.
i've tried treating array , doesn't work either. also, don't know if helps or not, indexes of arrays don't work either on uploaded version.
example, on localhost returning result of query returned 1 value: q->result()[0]
. doesn't work either, if take out index(key) , leave q->result()
works.
update: apparently objects have values retrieved database work fine objects on localhost when upload project on hosting site (the same php version) object wrapped in array on first position. else ever experienced this? or have idea of might going wrong?
eg. on localhost: $object->property === on hosting site: $object[0]->property.
check servers php version. syntax fun()[0]
works in late version of php. if version problem assigning variable first solve array case. like:
$temp = $o->fun(); $temp[0];
regarding object property problem var_dump($o) , @ type of object. should tell wrong.
-edit-
most database bindings have different fetch modes. mode determine if data fetched object, bindings variables, arrays of objects or arrays of arrays etc. might worth investigating particular binding library if there default mode, , if if default differ between hosting , local. check documentation library , compare php ini files locally , on hosting.
Comments
Post a Comment