Jump to content

XML DOM non-object error with getElementsByTagName()


bftwofreak

Recommended Posts

I've been getting the following error since I implemented an xml file to hold certain variable values.

Fatal error: Call to a member function getElementsByTagName() on a non-object in F:\Website\church\req\install\db_conn.php on line 12 

This is the xml document:

<?xml version="1.0" encoding="utf-8"?>
<settings>
    <server>se.r.v.er</server>
    <login>root</login>
    <pass>password</pass>
</settings>

and this is the php file

<?php
if (isset($_SESSION['form']) && $_SESSION['form'] == $_POST['form']) {
    
} else {
    
    $_SESSION['form'] = rand(0,100000000);
    
    echo '<td style="align: center; width: 100%;">';

    if (DB_FILE_EXISTS) {
        echo '<u>Current Settings</u><br/>';
        print_r('Server: ' . $mysql->getElementsByTagName('server') . '<br/>');
        print_r('Login: ' . $mysql->getElementsByTagName('login') . '<br/>');
        print_r('Password: ' . $mysql->getElementsByTagName('pass') . '<br/>');
    }
    
    echo '<br/><br/>';
    echo '<form method="post"><input type="hidden" name="form" value="' . $_SESSION['form'] . '">';
    echo '<input type="text" name="server">';
    echo '<input type="text" name="login">';
    echo '<input type="password" name="pass">';
    echo '<input type="submit" value="Submit"></form>';
}

?>

There is another file that opens the xml document as a new DOM document. Any ideas as to why I'm getting this error? Line 12 is the linke trying to display the server value.

Link to comment
Share on other sites

You are trying to call a member function in an object instance called $mysql. Your code does not show you ever instanciating this object instance, and the error message is saying that there is no object called $mysql so I would guess that you are not instanciating it anywhere.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.