Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6544709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:29:53+00:00 2026-05-25T11:29:53+00:00

In this php function I append to the node by calling that function in

  • 0

In this php function I append to the node by calling that function in a loop through ajax. The first time the call to appenchild succeeds. The second time there is a php error “call to undefined method”. I don’t understand why this happens.

Here is the php function

<?php

ini_set('display_errors', 1);
error_reporting(E_ALL);

function mysql_escape_mimic($inp) { 
    if(is_array($inp)) 
        return array_map(__METHOD__, $inp); 

    if(!empty($inp) && is_string($inp)) { 
        return str_replace(array('\\', "\0", "\n", "\r", "'", '"', "\x1a"), array('\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'), $inp); 
    } 

    return $inp; 
}


function add_url( $nodeid, $urlid, $urlname, $urllink ) {

$dom = new DOMDocument();
$dom->load('communities.xml');

$dom->formatOutput = true; 
$dom->preserveWhiteSpace = true;

// get document element  

$xpath = new DOMXPath($dom);
$nodes = $xpath->query("//COMMUNITY[@ID='$nodeid']"); 

if ($nodes->length) {

   $node = $nodes->item(0); 

   $xurls = $xpath->query("//COMMUNITY[@ID='$nodeid']/URLS");

   if ($xurls->length) {

   }
   else {
      $xurls = $dom->createElement("URLS"); 
      $node->appendChild($xurls);
   }

   $xurl = $dom->createElement("URL"); 
   $xurl->setAttribute("ID", $urlid);
   $xurls->appendChild($xurl);  /*  Function fails here second time, when node exists already */

   $xuname     = $dom->createElement("NAME");  
   $xunameText = $dom->createTextNode(mysql_escape_mimic($urlname));  
   $xuname->appendChild($xunameText); 
   $xurl->appendChild($xuname); 

   $xulink     = $dom->createElement("URLC");  
   $xulinkText = $dom->createTextNode(mysql_escape_mimic($urllink));  
   $xulink->appendChild($xulinkText); 
   $xurl->appendChild($xulink); 

}
   echo "from add_url urlid: ".$urlid." urlname ".$urlname." urllink ".$urllink;
$dom->save('communities.xml');
}

echo add_url(trim($_REQUEST['nodeid']), trim($_REQUEST['urlid']), trim($_REQUEST['urlname']), trim($_REQUEST['urllink']));

?>

Here is the XML structure.

<?xml version="1.0" encoding="ISO-8859-1"?>
<COMMUNITIES>
  <COMMUNITY ID="c000002">   
  <NAME>ID000002</NAME>
  <TOP>192</TOP>
  <LEFT>297</LEFT>
  <WIDTH>150</WIDTH>
  <HEIGHT>150</HEIGHT>
  <URLS>
    <URL ID="u000002">
       <NAME>Facebook.com</NAME>
       <URLC>http://www.facebook.com</URLC>
    </URL>
   </URLS>
  </COMMUNITY>
</COMMUNITIES>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:29:54+00:00Added an answer on May 25, 2026 at 11:29 am

    Try editing like this:

    ...
    if ($xurls->length) {
        $xurls = $xurls->item(0); // from DOMNodeList to DOMNode
    

    This is because later you’re appending a child to $xurls, so it must be an element (such as the one returned by createElement()) instead of a list, like PHP says:

    Fatal error: Call to undefined method DOMNodeList::appendChild()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm calling a php function from my $.ajax call to add a new item
$.getJSON('ajax_popup.php', function(data) { var popupDiv = decodeURIComponent(data.data); $('body').append( popupDiv ); }); This piece of
$.post('includes/script.php', $(this).serialize(), function(data) { $('body').append(data); }); alert ($('#new').length) php script is <php echo <div
i'm referring this address for function olLiTree PHP function that creates a nested ul
I have a JavaScript function, pop_item . I have to call this from PHP,
I am making an ajax call in jquery $.get(validate_isbn.php, {isbn: obj[16]}, function(answer) { console.log(answer);
How can I this PHP function include in jquery .html? PHP function: function trim_text($string,
I'm getting this problem: PHP Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable
This example is from php.net: <?php function Test() { static $a = 0; echo
How do you translate this perl subroutine into a PHP function? sub disagreement {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.