Help - Search - Members - Calendar
Full Version: Backslash Before Quotations
Zymic Webmaster Forums > Web Design & Development > Server Side Scripting > PHP
ultimategamer50
Ok I have created a Admin control panel in my site (using PHP) and I seem to be having troubles when I edit/create a file. Whenever there is a quotation in the file text I make, it always puts a backslash behind the quotation mark causing files not to work, I've tried stripslash() but that doesn't work. Can anyone help me?

editform.php:
CODE
<?php
echo '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <img src=http://bdcadmin.vndv.com/BDC.bmp /> <br> <br>';
$myFile = "./files/$_REQUEST[filename]";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "$_REQUEST[filetext]";
fwrite($fh, $stringData);
fclose($fh);
echo 'File was edited/created successfully! Please wait for page to refresh...<meta http-equiv="refresh" content="3; url=home.php" />';
?>
Bogey
Use file_put_contents() instead of fwrite... I don't know if that's the problem, but it's a good thing to do anyway...
swordz
Stop using the online text editor - it's not designed for writing code.

Use a text editor on your local machine and then ftp to transfer files up.

swordz
bbriniotis
By the way you might want to replace this one
$stringData = "$_REQUEST[filetext]";

with this one:
$stringData = $_REQUEST["filetext"];

There is no point haveing the variable between "", and you must have the filetext string inside quotes.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.