View Full Version : It is automatically inserting slashes in front of " ?

05-15-2008, 04:36 PM
Hi guys.

I have this script to post and saves contents to a .php file. However, if I try to add html to it, it will automatically insert slashes '\' in front of ' " '.

How would I disable that behavior in order to be able to parse html to the file?

$saving = $_REQUEST['saving'];
if ($saving == 1){
$data = $_POST['data'];
$file = "news.php";

$fp = fopen($file, "a") or die("Couldn't open $file for writing!");
fwrite($fp, $data) or die("Couldn't write values to file!");

echo "Saved to $file successfully!";


05-15-2008, 04:57 PM
$data = get_magic_quotes_gpc() ? stripslashes($_POST['data'];) : $_POST['data'];

05-15-2008, 04:59 PM
Just gets this: Parse error: syntax error, unexpected ';' in C:\Documents and Settings\Kasper\Skrivebord\xampplite\htdocs\Hjemmeside\write.php on line 31


05-15-2008, 05:09 PM
Oops, an extra semi-colon by typo, I think. Try

$data = get_magic_quotes_gpc() ? stripslashes($_POST['data']) : $_POST['data'];

05-15-2008, 05:29 PM
That worked! Thanks bud!

05-15-2008, 05:35 PM
That worked! Thanks bud!
You are welcome, BTW, I'd recommend you to check what's/why get_magic_quotes_gpc() (http://www.php.net/get_magic_quotes_gpc) ,if you haven't done this :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum