so i'm writing to a file, but it's truncating part of the content, but not
as i'd expect...

see the code below, it writes to the file fine, and everything should be
there, no errors. the problem occurs when it gets to writing
<text>.....</text> for some reason, it's truncating the content. but i'm not
sure why, or how? if i change the way i treat the $text before i put it into
the file, it'll truncate more/less. no idea why, or what it depends on to
truncate this stuff. i tried playing with wordwrap also as maybe it didn't
like sticking more than xxx characters per line, but this made no
difference. i'm writing a file that is over 5000 characters long. the file
writing seems to be fine with short lengths.

like i said, the code works fine, and the print $newContents prints out
exactly what it should write. however when it gets to writing (2 lines
later) it's truncated the $text portion of the $newContents, but it
shouldn't even have any recognition of their being any difference? surely?

i'm hoping that i'm missing something simple with variables passing by
reference or what-not, but i can't find anything to suggest it in the
manual. i'm not passing by reference as far as i know, but this is the only
way i can think of what the problem can be.

FYI: i'm using urlencode as certain characters are causing problems with the
XML structure of my files, and this seems to solve it nicely.

help???

much appreciated...

-skate-

--------------------------------
code
--------------------------------

  $newFile = "xml/".$type."/".$now.".xml";
  while(file_exists($newFile))
   $newFile = "xml/".$type."/".$now++.".xml";
  $text = $_POST['text'];
  $text = urlencode(stripslashes(nl2br($text)));
  $newContent = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
  $newContent .= "<!DOCTYPE item [\n";
  $newContent .= "\t<!ELEMENT title (#PCDATA)>\n";
  $newContent .= "\t<!ELEMENT date (#PCDATA)>\n";
  $newContent .= "\t<!ELEMENT text (#PCDATA)>\n";
  $newContent .= "]>\n";
  $newContent .= "<item>\n";
  $newContent .= "\t<title>".urlencode($_POST['title'])."</title>\n";
  $newContent .= "\t<date>".$now."</date>\n";
  $newContent .= "\t<text>".$text."</text>\n";
  $newContent .= "</item>";
  print $newContent;
  touch($newFile);
  $fp = fopen($newFile, "wb");
  fwrite( $fp, $newContent );
  fclose( $fp );



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to