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 8670359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:41:26+00:00 2026-06-12T18:41:26+00:00

Can anyone see what’s wrong with my code? The error I’m getting is as

  • 0

Can anyone see what’s wrong with my code? The error I’m getting is as follows:

Fatal error: Call to a member function saveXML() on a non-object in /path/to/php/file.php on line 35

Basically I’m just trying to update an XML nodeValue which changes the UI depending on the value set in the “AVAILABILITY” tag.

==================== UPDATE ====================

The XML file is now not being overwritten with the new value for the (‘STATUS’) node inside (‘AVAILABILITY’) tag, is there something I’m doing wrong?!

================================================

XML Structure

<?xml version="1.0" encoding="UTF-8"?>
<WORK>
    <AVAILABILITY>
        <STATUS>0</STATUS> // Not being changed?!
    </AVAILABILITY>
    <SLIDE>
        <ID>YY001</ID>
        <TITLE>YourEdentity</TITLE>
        <LINK>http://youredentity.campearce.co.uk</LINK>
        <THUMB>your_ed.png</THUMB>
        <CAPTION>This is YourEdentity</CAPTION>
    </SLIDE>
</WORK>

PHP Script:

<?php

$url = "../content/slides.xml";
$xml = simplexml_load_file($url);

if(!file_exists($url))
{
echo "Unable to locate file";
}
else
{
$root = $xml->WORK;
$slides = $root->SLIDE;

if(isset($_POST['action']) && !empty($_POST['action']))
{
    $action = $_POST['action'];
    switch($action)
    {
        case 'deleteslide' : delete_slide(); break;
        case 'createslide' : create_slide(); break;
        case 'changeavail' : change_avail($root, $_POST['status'], $xml, $url); break;
    }   
}
}

function change_avail($root_node, $status, $xml, $location){

$availability_node = $root_node->AVAILABILITY;
$status_node[0] = $availability_node->STATUS;
parse_str($status, $statustr);
$status_node[0] = $statustr;

file_put_contents($location, $xml->asXML());

echo $xml->asXML();
}

function save_toxml($xml, $location)
{
$fp = fopen($location, 'w');
fwrite($fp, $xml->asXML());
fclose($fp);
echo $xml->asXML();
}

?>
  • 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-06-12T18:41:27+00:00Added an answer on June 12, 2026 at 6:41 pm

    In function change_avail you didnt have variable $xml. Transmit this var:

    function change_avail($root_node, $status, DOMDocument $xml)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone see anything wrong with this login script: public function login($username, $pass, $remember)
can anyone see what is wrong with the following code. it's supposed to display
Can anyone see what is wrong with this bit of jquery code? I get
Can anyone see what's wrong with this code? SIZE_BG is 6MB as I am
Can anyone see anything that is wrong with this code it just isn't working...
Can anyone see anything that is wrong with this code it just isn't working...
Can anyone see an obvious error in this query? function getFixtureDetails($league, $date, $status) {
Can anyone see from the following function why I would be getting an Invalid
Can anyone see what is wrong with the code below? For some reason i
Can anyone see why i am getting the following error when i try to

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.