...

View Full Version : Stripslashes command - how do I implement it? (Probably a really easy question!)



chris_denman
06-25-2006, 02:56 PM
Hi,

I'm an extreme novice with PHP so please forgive my lack of knowledge!

I've done a script which basically writes what has been written into a textbox into a file (textfile.htm). However, I get backslashes ("\") all over the place. I know the command I need is "stripslashes", but I'm not entirely sure how to implement it.

Here is the code for the page where the file is written from:

<?php if ($action == "submit"){ $file = fopen("textfile.htm", "w"); fwrite($file, $textbox; fclose($file); } else { ?>

<form action="?" method="post"> <input type="hidden" name="action" value="submit" /> <input type="text" name="textbox" /> <input type="submit" value="Submit" /> </form> <?php } ?>

And here is the code for the page where textfile.htm is included:


<?PHP include("textfile.htm"); ?>

Basically, therefore, my ultimate goal is just for the page where the file is included to not have slashes all over it and I was wondering how I'd go about doing this:)

Thanks very much!!

Chris

lavinpj1
06-25-2006, 03:26 PM
Replace the include with an fread...


<?php
// get contents of a file into a string
$filename = "textfile.htm";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);

//echo out the text file with slashes removed
echo stripslashes($contents);
?>

~Phil~

chris_denman
06-25-2006, 03:28 PM
Replace the include with an fread...


<?php
// get contents of a file into a string
$filename = "textfile.htm";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);

//echo out the text file with slashes removed
echo stripslashes($contents);
?>

~Phil~
Hi,
Thanks very much... I'd thought I might need to reprocess it as a variable on the include page but wasn't sure how to go about it! :) :)

Chris

lavinpj1
06-25-2006, 03:30 PM
Welcome :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum