...

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



CaptainB
05-15-2008, 05: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?


<?php
$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!");

fclose($fp);
echo "Saved to $file successfully!";

}
?>

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

CaptainB
05-15-2008, 05: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

:confused:

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

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

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

abduraooft
05-15-2008, 06: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