PHP help

Discussion in 'PHP' started by buyer123, Oct 7, 2007.

  1. #1
    i have a little problem with a script that i have..

    $this->dom = new domDocument ; <---this is line 107 :)
    @$this->dom->loadHTML($this->data);
    foreach ($this->dom->getElementsByTagName('body') as $node) {
    $this->parseNode($node, $exclude);
    $object = $this->dom->createElement('div');
    ob_start();
    include 'php/includes/urlForm.inc.php';
    $content = ob_get_clean();
    $object->nodeValue = '{URL_FORM}';
    $references = $node->getElementsByTagName('*');
    $i = 0;
    foreach ($references as $reference) {
    if (!$i) {
    $node->insertBefore($object, $reference);
    }
    $i++;
    }
    }

    I have this code...

    when i try to execute it i get this line:


    Warning: domdocument() expects at least 1 parameter, 0 given in /home/...........php on line 107

    can anyone help me? thanks
     
    buyer123, Oct 7, 2007 IP
  2. james_r

    james_r Peon

    Messages:
    194
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    can you post your domDocument class? It's looking for a parameter, like:

    $this->dom = new domDocument($something);
     
    james_r, Oct 7, 2007 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #3
    nico_swd, Oct 7, 2007 IP
  4. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #4
    On line 107, you are creating a new instance of the object, but $this is used within the object, so you can't use $this.

    Try

    $blah = new domDocument ; then edit your code accordingly.
     
    matthewrobertbell, Oct 7, 2007 IP
  5. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #5
    You CAN create instances of objects on class members. There's nothing wrong with this.
     
    nico_swd, Oct 7, 2007 IP
  6. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #6
    That's me told, I'm still getting comfortable with oo php.
     
    matthewrobertbell, Oct 7, 2007 IP