Attempt to assign property of non-object in...
Posted on
16th Feb 2014 07:03 pm by
admin
I'm having issues with the following function in PHP 5...
function getTreeWithChildren()
{
Did you know?Explore Trending and Topic pages for more stories like this.
$category_id = $this->fields['id'];
$parent_id = $this->fields['parent'];
$this->DB->build( array( 'select' => join(',', $this->getFields()),
'from' => $this->table,
'order' => $this->fields['sort']
) );
$this->DB->execute();
// create a pseudo root level object
$root = new stdClass;
$root->$category_id = 0;
$root->children = array();
$arr = array($root);
// populate array and create empty child array
while ($row = $this->DB->fetch()) {
$arr[$row->$category_id] = $row;
$arr[$row->$category_id]->children = array();
}
// build child data
foreach ($arr as $id => $row) {
if (isset($row->$parent_id))
$arr[$row->$parent_id]->children[$id] = $id;
}
return $arr;
}
I'm getting the error
QuoteAttempt to assign property of non-object in ... on line 391
which is...
$arr[$row->$category_id]->children = array();
I've tried typecasting "$this->DB->fetch()" to an object with...
while ($row = (object) $this->DB->fetch()) {
but get a maximum execution time exceeded error instead.
The code was originally written for PHP 4 so I suspect it might be a way the objects are handled and the use of stdClass()?
I'd be extremely grateful if somebody could give me pointers to make this PHP5 compatible (5.2.9)? Thanks in advance
No comments posted yet
Your Answer:
Login to answer
84
54
Other forums
Select Rows as Columns..
is there a way to select COLUMN_NAME from user_tab_columns where table_name='TABLENAME';
and ha
Best way to cross matching large datasets
Hi,
Im running a script where am I cross matching about 200 000 data sets with each other. Ea
A little help in c#
i am doing a simple paint program using c# i want to draw with the mouse so i wrote the code of the
login from external site
Hi my new experience begins, Now what i am trying to do is i make three pages, login.php logout.php
Find current logon time
Hi,
in my sql script i want to query and find out the logon time of the current session.
<
Custom list order
Hi there,
I have checked this tutorial and it's great till the point where I want to display
Log $_POST
How would i log submits on a form, by everyone? I want to then echo the number of submissions.
Retrieving innerHTML with cURL?
Hey all (sorry I know I'm a leecher, but I soon won't be. This is my first PHP project, but not my l
Querying info from one table based on info in another
Hi, I am currently trying to make a part for my user driven website where one user can subscribe to
Email Form Syantax Issue 2
How to make this look FROM:"OUR TEAM" instead of FROM:abc@mail.com
$headers = "