erbilacx Posted April 11, 2011 Share Posted April 11, 2011 Keep getting this error from line 19 (Notice: Trying to get property of non-object in /clientdata/zeus-dynamic-1/s/o/blahblah/www/tyson/onion.php on line 18)... have no idea how to get rid of it. Do I have to use isset? If so.. where??? (obviously I've replaced site address with website) include('simple_html_dom.php'); $story = array(); getArticles('website'); function getArticles($page) { global $story, $desc, $read; $html = new simple_html_dom(); $html->load_file($page); $items = $html->find('div[id=story_content]'); foreach($items as $post) { $story[] = array($post->children(0)->plaintext, $post->children(2)->next_sibling()->innertext, $post->children(4)->innertext); } } $i = 0; foreach($story as $item) { $syurl = str_replace('href="', 'href="http://website', $item[2]); echo '<p class="storytitle">' . $item[0] . '</p>'; echo '<p class="storyexcerpt">' . $item[1] . '</p>'; echo '<p class="storyread">' . $syurl . '</p>'; if (++$i == 3) break; } Any ideas? This line is causing the issue: $story[] = array($post->children(0)->plaintext, $post->children(2)->next_sibling()->innertext, $post->children(4)->innertext); Likewise, it does post the 3 storys below the 2 error lines...? Quote Link to comment Share on other sites More sharing options...
Adam Posted April 11, 2011 Share Posted April 11, 2011 I'd guess that there are no children nodes of $post, so the children() method doesn't return an object. Use var_dump to view what $post contains, and post here if you're unsure. Quote Link to comment Share on other sites More sharing options...
erbilacx Posted April 11, 2011 Author Share Posted April 11, 2011 Kept dumping this: object(simple_html_dom_node)#164 ( { ["nodetype"]=> int(1) ["tag"]=> string(3) "div" ["attr"]=> array(1) { ["id"]=> string(13) "story_content" } ["children"]=> array(5) { [0]=> object(simple_html_dom_node)#166 ( { ["nodetype"]=> int(1) ["tag"]=> string(1) "a" ["attr"]=> array(1) { ["href"]=> string(13) "/article/3212" } ["children"]=> array(1) { [0]=> object(simple_html_dom_node)#167 ( { ["nodetype"]=> int(1) ["tag"]=> string(2) "h4" ["attr"]=> array(0) { } ["children"]=> array(0) { } ["nodes"]=> array(1) { [0]=> object(simple_html_dom_node)#168 ( { ["nodetype"]=> int(3) ["tag"]=> string(4) "text" ["attr"]=> array(0) { } ["children"]=> array(0) { } ["nodes"]=> array(0) { } ["parent"]=> *RECURSION* ["_"]=> array(1) { [4]=> string(29) "ARMADA NIGHTS. HQ. SAT MAY 14" } ["dom:private"]=> object(simple_html_dom)#1 (18) { ["root"]=> object(simple_html_dom_node)#2 ( { ["nodetype"]=> int(5) ["tag"]=> string(4) "root" ["attr"]=> array(0) { } ["children"]=> array(2) { [0]=> object(simple_html_dom_node)#4 ( { ["nodetype"]=> int(6) ["tag"]=> string(7) "unknown" ["attr"]=> array(0) { } ["children"]=> array(0) { } ["nodes"]=> array(0) { } ["parent"]=> *RECURSION* ["_"]=> array(2) { [0]=> int(2) [4]=> string(121) "" } ["dom:private"]=> *RECURSION* } [1]=> object(simple_html_dom_node)#6 ( { ["nodetype"]=> int(1) ["tag"]=> string(4) "html" ["attr"]=> array(1) { ["xmlns"]=> string(28) "http://www.w3.org/1999/xhtml" } ["children"]=> array(2) { [0]=> object(simple_html_dom_node)#8 ( { ["nodetype"]=> int(1) ["tag"]=> string(4) "head" ["attr"]=> array(0) { } ["children"]=> array(11) { [0]=> object(simple_html_dom_node)#10 ( { ["nodetype"]=> int(1) ["tag"]=> string(4) "meta" ["attr"]=> array(2) { ["http-equiv"]=> string(15) "X-UA-Compatible" ["content"]=> string(13) "IE=EmulateIE7" } ["children"]=> array(0) { } ["nodes"]=> array(0) { } ["parent"]=> *RECURSION* ["_"]=> array(4) { [0]=> int( [2]=> array(2) { [0]=> int(0) [1]=> int(0) } [3]=> array(2) { [0]=> array(3) { [0]=> string(1) " " [1]=> string(0) "" [2]=> string(0) "" } [1]=> array(3) { [0]=> string(1) " " [1]=> string(0) "" [2]=> string(0) "" } } [7]=> string(0) "" } ["dom:private"]=> *RECURSION* } [1]=> object(simple_html_dom_node)#12 ( { ["nodetype"]=> int(1) ["tag"]=> string(4) "meta" ["attr"]=> array(2) { ["http-equiv"]=> string(12) "Content-Type" ["content"]=> string(29) "text/html; charset=ISO-8859-1" .... over and over... Quote Link to comment Share on other sites More sharing options...
Adam Posted April 11, 2011 Share Posted April 11, 2011 Could you post it again within tags? Quote Link to comment Share on other sites More sharing options...
erbilacx Posted April 11, 2011 Author Share Posted April 11, 2011 Put it in code tags, it dumps as one line.. so you might have to copy and paste elsewhere to view.. Quote Link to comment Share on other sites More sharing options...
Adam Posted April 11, 2011 Share Posted April 11, 2011 Ha.. right click and view the source, then copy from there. That will preserve the formatting.. Quote Link to comment Share on other sites More sharing options...
erbilacx Posted April 11, 2011 Author Share Posted April 11, 2011 This is some of the top... object(simple_html_dom_node)#164 ( { ["nodetype"]=> int(1) ["tag"]=> string(3) "div" ["attr"]=> array(1) { ["id"]=> string(13) "story_content" } ["children"]=> array(5) { [0]=> object(simple_html_dom_node)#166 ( { ["nodetype"]=> int(1) ["tag"]=> string(1) "a" ["attr"]=> array(1) { ["href"]=> string(13) "/article/3212" } ["children"]=> array(1) { [0]=> object(simple_html_dom_node)#167 ( { ["nodetype"]=> int(1) ["tag"]=> string(2) "h4" ["attr"]=> array(0) { } ["children"]=> array(0) { } ["nodes"]=> array(1) { [0]=> object(simple_html_dom_node)#168 ( { ["nodetype"]=> int(3) ["tag"]=> string(4) "text" ["attr"]=> array(0) { } ["children"]=> array(0) { } ["nodes"]=> array(0) { } ["parent"]=> *RECURSION* ["_"]=> array(1) { [4]=> string(29) "ARMADA NIGHTS. HQ. SAT MAY 14" } ["dom:private"]=> object(simple_html_dom)#1 (18) { ["root"]=> object(simple_html_dom_node)#2 ( { ["nodetype"]=> int(5) ["tag"]=> string(4) "root" ["attr"]=> array(0) { } ["children"]=> array(2) { [0]=> object(simple_html_dom_node)#4 ( { ["nodetype"]=> int(6) ["tag"]=> string(7) "unknown" ["attr"]=> array(0) { } ["children"]=> array(0) { } ["nodes"]=> array(0) { } ["parent"]=> *RECURSION* ["_"]=> array(2) { [0]=> int(2) [4]=> string(121) "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">" } ["dom:private"]=> *RECURSION* } [1]=> object(simple_html_dom_node)#6 ( { ["nodetype"]=> int(1) ["tag"]=> string(4) "html" ["attr"]=> array(1) { ["xmlns"]=> string(28) "http://www.w3.org/1999/xhtml" } ["children"]=> array(2) { [0]=> object(simple_html_dom_node)#8 ( { ["nodetype"]=> int(1) ["tag"]=> string(4) "head" ["attr"]=> array(0) { } ["children"]=> array(11) { [0]=> object(simple_html_dom_node)#10 ( { ["nodetype"]=> int(1) ["tag"]=> string(4) "meta" ["attr"]=> array(2) { ["http-equiv"]=> string(15) "X-UA-Compatible" ["content"]=> string(13) "IE=EmulateIE7" } ["children"]=> array(0) { } ["nodes"]=> array(0) { } ["parent"]=> *RECURSION* ["_"]=> array(4) { [0]=> int( [2]=> array(2) { [0]=> int(0) [1]=> int(0) } [3]=> array(2) { [0]=> array(3) { [0]=> string(1) " " [1]=> string(0) "" [2]=> string(0) "" } [1]=> array(3) { [0]=> string(1) " " [1]=> string(0) "" [2]=> string(0) "" } } [7]=> string(0) "" } ["dom:private"]=> *RECURSION* } [1]=> object(simple_html_dom_node)#12 ( { ["nodetype"]=> int(1) ["tag"]=> string(4) "meta" ["attr"]=> array(2) { ["http-equiv"]=> string(12) "Content-Type" ["content"]=> string(29) "text/html; charset=ISO-8859-1" } ["children"]=> array(0) { } ["nodes"]=> array(0) { } ["parent"]=> *RECURSION* ["_"]=> array(5) { [0]=> int(10) [2]=> array(2) { [0]=> int(0) [1]=> int(0) } [3]=> array(2) { [0]=> array(3) { [0]=> string(1) " " [1]=> string(0) "" [2]=> string(0) "" } [1]=> array(3) { [0]=> string(1) " " [1]=> string(0) "" [2]=> string(0) "" } } [7]=> string(2) " /" [1]=> int(0) } ["dom:private"]=> *RECURSION* } [2]=> object(simple_html_dom_node)#14 ( { ["nodetype"]=> int(1) ["tag"]=> string(5) "title" ["attr"]=> array(0) { } ["children"]=> array(0) { } ["nodes"]=> array(1) { [0]=> object(simple_html_dom_node)#15 ( { ["nodetype"]=> int(3) ["tag"]=> string(4) "text" ["attr"]=> array(0) { } ["children"]=> array(0) { } ["nodes"]=> array(0) { } ["parent"]=> *RECURSION* ["_"]=> array(1) { [4]=> string(12) "ONION - HOME" } ["dom:private"]=> *RECURSION* } } ["parent"]=> *RECURSION* ["_"]=> array(3) { [0]=> int(12) [7]=> string(0) "" [1]=> int(14) } ["dom:private"]=> *RECURSION* } [3]=> object(simple_html_dom_node)#17 ( { ["nodetype"]=> int(1) ["tag"]=> string(4) "link" ["attr"]=> array(3) { ["type"]=> string( "text/css" ["rel"]=> string(10) "stylesheet" ["href"]=> string(22) "/floatbox/floatbox.css" } ["children"]=> array(0) { } ["nodes"]=> array(0) { } ["parent"]=> *RECURSION* ["_"]=> array(5) { [0]=> int(15) [2]=> array(3) { [0]=> int(0) [1]=> int(0) [2]=> int(0) } [3]=> array(3) { [0]=> array(3) { [0]=> string(1) " " [1]=> string(0) "" [2]=> string(0) "" } [1]=> array(3) { [0]=> string(1) " " [1]=> string(0) "" [2]=> string(0) "" } [2]=> array(3) { [0]=> string(1) " " [1]=> string(0) "" [2]=> string(0) "" } } [7]=> string(2) " /" [1]=> int(0) } ["dom:private"]=> *RECURSION* } [4]=> object(simple_html_dom_node)#19 ( { ["nodetype"]=> int(1) ["tag"]=> string(6) "script" ["attr"]=> array(2) { ["type"]=> string(15) "text/javascript" ["src"]=> string(21) "/floatbox/floatbox.js" } ["children"]=> array(0) { } ["nodes"]=> array(1) { [0]=> object(simple_html_dom_node)#20 ( { ["nodetype"]=> int(3) ["tag"]=> string(4) "text" ["attr"]=> array(0) { } ["children"]=> array(0) { } ["nodes"]=> array(0) { } ["parent"]=> *RECURSION* ["_"]=> array(1) { [4]=> string(14) "___noise___190" } ["dom:private"]=> *RECURSION* } } ["parent"]=> *RECURSION* ["_"]=> array(5) { [0]=> int(17) [2]=> array(2) { [0]=> int(0) [1]=> int(0) } [3]=> array(2) { [0]=> array(3) { [0]=> string(1) " " [1]=> string(0) "" [2]=> string(0) "" } [1]=> array(3) { [0]=> string(1) " " [1]=> string(0) "" [2]=> string(0) "" } } [7]=> string(0) "" [1]=> int(19) } ["dom:private"]=> *RECURSION* } [5]=> object(simple_html_dom_node)#22 ( { ["nodetype"]=> int(1) ["tag"]=> string(6) "script" ["attr"]=> array(1) { ["type"]=> string(15) "text/javascript" } ["children"]=> array(0) { } ["nodes"]=> array(1) { [0]=> object(simple_html_dom_node)#23 ( { ["nodetype"]=> int(3) ["tag"]=> string(4) "text" ["attr"]=> array(0) { } ["children"]=> array(0) { } ["nodes"]=> array(0) { } ["parent"]=> *RECURSION* ["_"]=> array(1) { [4]=> string(14) "___noise___189" } ["dom:private"]=> *RECURSION* } } ["parent"]=> *RECURSION* ["_"]=> array(5) { [0]=> int(20) [2]=> array(1) { [0]=> int(0) } [3]=> array(1) { [0]=> array(3) { [0]=> string(1) " " [1]=> string(0) "" [2]=> string(0) "" } } [7]=> string(0) "" [1]=> int(22) } ["dom:private"]=> *RECURSION* } [6]=> object(simple_html_dom_node)#25 ( { ["nodetype"]=> int(1) ["tag"]=> string(4) "link" ["attr"]=> array(3) { ["rel"]=> string(10) "stylesheet" & Quote Link to comment Share on other sites More sharing options...
erbilacx Posted April 11, 2011 Author Share Posted April 11, 2011 Or am I using var_dump incorrectly if it keeps repeating...? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.