0

i try to edit the text of an XML file from my page edit.php. It works fine if i test it in "localhost", the xml file is updated as expected.

But, when i put the files on internet, and i try to edit the text from there, it seems to be ok, but then i refresh the page, and the text in the edit.php is still the same as before, and nothing has been updated. Do you know where this comes from? is there a problem with my "form" ?

here is my code :

<body>

        <?php
        /* READ */
        $dom = new DomDocument();
        $dom->load('edition.xml');

        $_haut = $dom->getElementsByTagName('haut')->item(0);
        $haut = $_haut->firstChild->nodeValue;

        /* WRITE */
        if ( isset($_POST['cache']) ){
            $haut = stripslashes($_POST['haut']);
            $_haut->firstChild->nodeValue = $haut;

            $dom->save('edition.xml');
        }
        ?>

        <div>
            <h4 style="float:left;">Update the text</h4>
            <div style="clear:both;"></div>


            <form method="post" action="edition.php">
                <p>
                <label for="textarea1">the text : </label><br />
                <textarea rows="14" cols="80" name="haut" id="textarea1"><?php echo $haut ?></textarea>
                </p>
                <input type="hidden" id="cache" name="cache"/>
                <p><input type="submit" value="Envoyer" /></p>
            </form>


        </div>
</body>

Thanks for your help

Paul
  • 6,108
  • 14
  • 72
  • 128
  • 2
    If where you have them hosted is on a *nix box, don't forget to add read/write permissions to the file. Also, check what's returned by `$dom->save('edition.xml')` to see if it generated an error. – Mr. Llama Oct 31 '11 at 16:08
  • Do you receive any errors? Put `error_reporting(E_ALL);` at the top of your script and then run it and tell us any errors it shows. Also make sure the path to the file is correct. – imkingdavid Oct 31 '11 at 16:09
  • 1
    "on the internet"... **shudder** – Marc B Oct 31 '11 at 16:10
  • Thanks, it works fine, "on the internet" ! yeah you were right i had to put "read and write" on my file, thanks a lot, Cheers! – Paul Oct 31 '11 at 18:07

1 Answers1

1

My best guess is the user php is running as does not have the permissions to do so.

dstarh
  • 4,976
  • 5
  • 36
  • 68
  • thanks, sorry if you saw my first comment, i mixed it up, i had to change the permissions in the FTP too! Thanks! – Paul Oct 31 '11 at 20:50