Re: PHP inside code problem

From: Date: Tue, 07 Aug 2001 11:03:39 +0000
Subject: Re: PHP inside code problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-61581@lists.php.net to get a copy of this message
try this: if (!($html_support)) { $user_message = htmlspecialchars(stripslashes($user_message)); } Wagner Tomy Web Developer Editus S.A. ----- Original Message ----- From: "Nick K." <geteasy@seed.net.tw> To: <php-general@lists.php.net> Sent: Tuesday, August 07, 2001 12:11 PM Subject: [PHP] PHP inside code problem 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 &quot; . 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 !±!±^^\&quot; (!±!± 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("<","&lt;","$user_message"); $user_message = eregi_replace(">","&gt;","$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

« previous php.general (#61581) next »