thanks for your replies, but what i would really like to do is remove these characters, rather than change them into ascii equivalents.
ive succeded in doing this by using:
// Replace Characters with Nothing
$ReplaceThese = array("\'","\"","\"");
$buffer = str_replace($ReplaceThese, '', $buffer);
...im sure i tried that before and it didnt work.. must have got my ' and " mixed up.
anyway... ive got that working but now im having another problem, id like to do the whole sequence in one swoop - so, write the latest posts to the txt file, close it, then open it to take out the bad characters...
only trouble is i get this error when trying to do so:
Parse error: parse error, unexpected T_VARIABLE in /home/1/public_html/1/1/forumlatest.php on line 29
my code is:
<?php
$myFile = "latest.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$content = "content=";
fwrite($fh, $content);
include ("GetLatestMessage.php");
echo "<font face=\"verdana\" size=\"1\"><b>Latest Posts:</b></font><br>";
$LastMsg=GetLatestMessage('1.net/1/1/forum','/users/1/public_html/1/1/forum',5);
for ($i=0;$i<=4;$i++){
echo "<a href=\"http://",$LastMsg['URL'][$i],"\" target=\"NEU\"><font face=\"verdana\" size=\"1\">",$LastMsg['subj'][$i],"</a> <br>by ",$LastMsg['auth'][$i],"</font><br><br>";
}
$theMessage = "";
for ($i=0;$i<=4;$i++){
$theMessage .= "".$LastMsg['subj'][$i]."<br>by ".$LastMsg['auth'][$i]."<br><br>";
}
fwrite($fh, $theMessage);
fclose($fh)
// Read File and Save to Buffer then Close
$myFileR = "latest.txt";
$filesize = filesize($myFileR);
$fhR = fopen($myFileR, "r") or die("can\'t open file");
$buffer = fread($fhR,$filesize);
fclose($fhR);
//Open latest.txt and strip characters
$fhR = fopen($myFileR, "w") or die("can\'t open file");
// Replace Spaces in UserFileName With Underscores
$ReplaceThese = array("\'","\"","\"");
$buffer = str_replace($ReplaceThese, '', $buffer);
// Get Rid of Slashes (\)
$buffer = stripslashes($buffer);
// Write New Entry Then Write Buffered File
fputs($fhR,"$buffer");
fclose($fhR);
?>
both the scripts work fine on there own so im not sure where im im going wrong, the line the error refers to is:
$myFileR = "latest.txt";
any ideas on what im doing wrong?
thanks