Current location: Hot Scripts Forums » Programming Languages » PHP » PHP Fatal error: Call to a member function item() on a non-object


PHP Fatal error: Call to a member function item() on a non-object

Reply
  #1 (permalink)  
Old 08-25-06, 07:46 AM
mohit's Avatar
mohit mohit is offline
Newbie Coder
 
Join Date: Jul 2006
Location: India
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Fatal error: Call to a member function item() on a non-object

hi friends...
i'm getting this error..
in my php code.

PHP Fatal error: Call to a member function item() on a non-object
PHP Code:

$element=$dom->getElementsByTagName("Result");

                    
$length $element->length;
                    for (
$x=0;$x $length;$x++)
                    {
                         print 
"Element Name: .$elements->item($x)->nodeName."\n";
                         print "
Element Value".$elements->item($x)->nodeValue."\n";
                    } 
you can see where i'm using item.

i'm using domobject.
any help..

Thanks
mohit

Last edited by nico_swd; 08-25-06 at 07:59 AM.
Reply With Quote
  #2 (permalink)  
Old 08-25-06, 07:58 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Lol.. what is that? Seems like someone tried to convert Javascript to PHP.

Anyways, what the error is saying is, that $elements isn't an object. Try using $dom or $element instead.

And could you maybe post the whole code?
Reply With Quote
  #3 (permalink)  
Old 08-25-06, 08:03 AM
mohit's Avatar
mohit mohit is offline
Newbie Coder
 
Join Date: Jul 2006
Location: India
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Smile

oops..i did mistake i was using $elements instead of $element and nico i never worked on java script.

Any way thanks a lot..
mohit.
Reply With Quote
  #4 (permalink)  
Old 08-25-06, 09:35 AM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
There is also a missing double-quote in the following line -
PHP Code:

print "Element Name: .$elements->item($x)->nodeName."n"; 

__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP upload prob minority ASP 1 06-27-05 08:35 AM
PHP Error Fairnie PHP 8 06-26-04 07:15 AM
Need Epinions-lite system in PHP & MYSQL wali001 Job Offers & Assistance 4 01-12-04 06:02 AM
accessing existing ISP email with a PHP webmail script. nlancaster PHP 1 01-07-04 03:28 AM
Object Oriented Programming Stefan PHP 29 12-30-03 11:22 AM


All times are GMT -5. The time now is 07:27 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.