I have a form that writes to a text file (which updates the news via the convienence of the web)... its a text area form and it passes the information into the text file using the following code... my problem is that if, in the $newsEntry field, I quote something or use any character that is a reserved character in PHP such as " , ' , and so on, it replaces it with backslash THEN the character. so " would become \" inside the text file. This is really annoying, if someone could help me it would be greatly appriciated.:
START PHP CODE (ITS A FUNCTION)
{
$TheFile = "./data/news.txt"; // Points to news file
$Open = fopen($TheFile,"a"); // Opens the file and is ready to write to the end of the file
str_replace("\\\"","\"",$Open);
$datepattern = "[0-9]+\.";
if(($Open) && (eregi($datepattern, $date))) // If the file is open, then...
{
fwrite($Open, "\n$newsEntry\n$date\n"); // Write the date and news entry to the file
fclose($Open);
print("Write news fucntion completed <font color='#FF8000'><b>sucessfully!</b></font><tt> <br>Inputs: <br><br> Date: $date <br> Entry: $newsEntry</tt> <br><br><a href='../index.php'>Return to index.php</a>");
}
else
{
// If failure, print debugging info...
print("<b>[DEBUGGING NEEDED]</b><br><br>");
if(eregi($datepattern, $date))
{
print("The date input ( $date ) must begin and end with a digit.");
}
if($Open)
{
print("File '\"Open\" = $Open <br> File \"TheFile\" = $TheFile <br><br>");
}
print("Write News function <font color='#FF0000'><b>failed</b></font>!<br><tt> Inputs: <br><br> Date: $date <br> Entry: $newsEntry</tt><br><br><a href='../index.php'>Return to index.php</a>");
print("<br><b>[END DEBUGGING]</b><br>");
}
} // End Write News
END PHP CODE
Thanks