PHP inside code problem
| From: | Nick K. | Date: | Tue, 07 Aug 2001 10:11:46 +0000 |
| Subject: | PHP inside code problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-61572@lists.php.net to get a copy of this message | ||
hi there
---------------------------------------------
if ($act = "add") //Add the message...
{
if (!empty($user_name) && !empty($user_ip) && !empty($user_message) &&
!empty($user_sex)) {
if (!($html_support))
{
$user_message = htmlspecialchars("$user_message");
}
$user_message = ereg_replace("\n","<br>","$user_message");
$userinfo =
"$user_name§§$user_sex§§$user_ip§§$user_message§§$user_date"."\n";
$fp = fopen("$filename",'a');
flock($fp,2);
fwrite($fp, $userinfo);
flock($fp,1);
fclose($fp);
header("Location: index.php");
setcookie("cuser",$user_name,time()+(3600*24*365),"/","$SERVER_NAME");
exit;
}
}
---------------------------------------------
The code above is what I use for processing messages....
Everytime when I'm trying to use the function, htmlspecialchars(),
it'll replace " with " . After that, I save the data and print out again,
the result will add "\" after the data... ( I don't want the extra "\")
There is an example.
When I try to type in ^^" to be my new message, it suppose to show the same thing.
However, in the saved data, it shows §§^^\" (§§ is what I use to different from
different filez)
I don't want the extra "\"....
however, I tried the way in below:
I use
$user_message = eregi_replace("<","<","$user_message");
$user_message = eregi_replace(">",">","$user_message");
instead of the original one which is
$user_message = htmlspecialchars("$user_message");
however, when I check the saved file, it still have and extra \ before the characters " .
god damn it....
I run this code in windows98SR2, maybe it's micro$oft's problem, is it?
plz help me.....thx dudes
....nick