www.webdeveloper.com
Results 1 to 9 of 9

Thread: PHP script FATAL ERROR !!!!

  1. #1
    Join Date
    May 2004
    Location
    NS, Canada
    Posts
    108

    Question PHP script FATAL ERROR !!!!

    Here is a snipit of code from my counter.php script:

    PHP Code:
    <?php
    $string 
    file_get_contents('txtfolder/statistics.xml'); 
    $pos strpos($string $user_ip);
    $dom "txtfolder/statistics.xml";
    $DomDocument = &domxml_open_file($dom);
    $tags $DomDocument->get_elements_by_tagname('visitors');
    if (!
    in_array($user_ip$banned)) {
        if(empty(
    $tags)) 
            {
            } 
        else 
            {
            
    $ip_addresses = &$tags[0]; 
            
    $ip $DomDocument->create_element('ip'); 
            
    $ip->set_attribute('address'$user_ip); 
            
    $ip->set_attribute('browser'$browser);
            
    refer($ip$domain$_SERVER['HTTP_REFERER']);
            
    $ip_addresses->append_child($ip); 
            
    $DomDocument->dump_file($domfalsetrue);
            }
        }
    }  
    ?>
    Line 82:

    PHP Code:
    $DomDocument = &domxml_open_file($dom); 
    Line 83:

    PHP Code:
    $tags $DomDocument->get_elements_by_tagname('visitors'); 
    Here is the error I am receiving when I load the page calling that script:

    Fatal error: Call to a member function on a non-object in /export/home1/http/.users/a0/00/10/43/bradleya.ca/www/txtfolder/counter.php on line 83

    The PHP version my webspace provider is using is 4.4. All the xml related libraries have been built in and the php.ini file is loading the module for domxml (php_domxml.dll). I haven't made any changes to my xml file, and here is a snipit of the code from it:

    Code:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <siteinfo>
    	<visitors><ip address="12.34.56.78" browser="Other Browsers" referer="www.google.com"/></visitors>
    </siteinfo>
    I posted this issue before but I have more up to date information this time, and I'm hoping this time someone might have an idea what's causing this?


  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,386
    Should line 82 be...
    PHP Code:
     $DomDocument =& new domxml_open_file($dom); 
    ...?
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    May 2004
    Location
    NS, Canada
    Posts
    108
    I did that and this error came up:

    Fatal error: Cannot instantiate non-existent class: domxml_open_file in /export/home1/http/.users/a0/00/10/43/bradleya.ca/www/txtfolder/counter.php on line 82

    ??

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,386
    Based on the sample on this page, how about trying this to replace lines 82-83?
    PHP Code:
    if (!$DomDocument domxml_open_file($dom)) {
      echo 
    "Error while parsing the document\n";
      exit;
    }
    $tags $DomDocument->get_elements_by_tagname('visitors'); 
    I'm sort of stumbling in new territory for me here, just hoping maybe I can throw a dart that happens to find a solution (and maybe learn a little something while I'm doing it).
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  5. #5
    Join Date
    Mar 2004
    Posts
    3,056
    Well in PHP5 it'd be
    PHP Code:
    $DomDocument = new domDocument();
    $DomDocument->load($dom); 
    Does that work by any chance?

  6. #6
    Join Date
    May 2004
    Location
    NS, Canada
    Posts
    108
    Thanks for the reply guys

    NogDog: It did echo that phrase, so what does that mean? There's an error with line 82 as well??

    Stephen Philbin: My webspace provider is using 4.4 so I figured it woudln't work and this is what it returned -

    Fatal error: Call to undefined function: load() in /export/home1/http/.users/a0/00/10/43/bradleya.ca/www/txtfolder/counter.php on line 83

  7. #7
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,386
    Try using a full pathname for the file, perhaps something like:
    PHP Code:
    $dom realpath("txtfolder/statistics.xml");
    if(empty(
    $dom))
    {
      die(
    "Uh-oh! Bad file name, perhaps?");

    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  8. #8
    Join Date
    May 2004
    Location
    NS, Canada
    Posts
    108
    $dom = realpath("txtfolder/statistics.xml");
    NogDog you're a genius LOL it was "realpath" I was missing, I KNEW it wasn't those lines, I read everything I could on domxml and I was so lost
    Thanks again!

  9. #9
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,386
    Not so sure it's genius as much as it's stubbornness.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles