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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.