I have the code as in the following:


$name= "Test";
$phone= "123-456-7890";
$email = "myem...@mymail.com";
$comments = "Test Only";

$string = "<message>\n<name>" . $name . "</name>\n<phone>" . $phone . 
          $email . "</email>\n<comments>" .  $comments . 

//If file exists. append, otherwise create
$file = "messages.xml";
$fh = fopen($file,"a");
$lines = file($file);

//Output a line of the file until the end is reached
foreach($lines as $line) {

   if (trim($line) == "<messages>") {

    $line = "<messages>" . $string; // If string, change it.
    echo $line . "<br>";
    fwrite($fh, $line);
   else {
    // If not don't write anything
   echo $line . "<br>";

  fclose($file); // Close the file.

For some reason, it is writing out the lines, but it is not f-writing to the 
file. Here is the file that is meant to be edited:

<comments>This is my message board!</comments>

Have I missed something here? How come the file cannot perform fwrite actions?

Thanks for your help.
The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail.

Reply via email to