Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting \ infront of ' and " etc... when write to file

Status
Not open for further replies.

BPMan

Programmer
Jun 25, 2002
163
US
I am having a user update files using php. My problem is i get \ infront of characters that would normally need them in a string like " or '. I am not sure how to stop these.
is there another way i can do the following:

<?php
include 'header2.ht';

error_reporting(0);
$read = fopen(&quot;CPMAIN.TXT&quot;, &quot;r&quot;) or die(&quot;<br /><font face=\&quot;Verdana\&quot;>Sorry! There is no access to this file directly. You must follow a link. <br /><br />Please click your
browser's back button. </font><br><br><a href=\&quot; src=\&quot; alt=\&quot;miracle 2\&quot; border=\&quot;0\&quot;></a>&quot;);
// let's turn errors back on so we can debug if necessary
error_reporting(1);

$cpd = &quot;&quot;;
while(!feof($read)){
$cpd .= fread($read, 10000); // reduce number to save server load
}
fclose($read);

error_reporting(0);
$read = fopen(&quot;CEMAIN.TXT&quot;, &quot;r&quot;) or die(&quot;<br /><font face=\&quot;Verdana\&quot;>Sorry! There is no access to this file directly. You must follow a link. <br /><br />Please click your
browser's back button. </font><br><br><a href=\&quot; src=\&quot; alt=\&quot;miracle 2\&quot; border=\&quot;0\&quot;></a>&quot;);
// let's turn errors back on so we can debug if necessary
error_reporting(1);

$ced = &quot;&quot;;
while(!feof($read)){
$ced .= fread($read, 10000); // reduce number to save server load
}
fclose($read);

error_reporting(0);
$read = fopen(&quot;NEWS.TXT&quot;, &quot;r&quot;) or die(&quot;<br /><font face=\&quot;Verdana\&quot;>Sorry! There is no access to this file directly. You must follow a link. <br /><br />Please click your
browser's back button. </font><br><br><a href=\&quot; src=\&quot; alt=\&quot;miracle 2\&quot; border=\&quot;0\&quot;></a>&quot;);
// let's turn errors back on so we can debug if necessary
error_reporting(1);

$newd = &quot;&quot;;
while(!feof($read)){
$newd .= fread($read, 10000); // reduce number to save server load
}
fclose($read);

//FUNCTION BEGINS HERE##################
if(isset($_POST[&quot;cp&quot;]))
{

error_reporting(0);
$read = fopen(&quot;CPMAIN.TXT&quot;, &quot;w&quot;) or die(&quot;<br /><font face=\&quot;Verdana\&quot;>Sorry! There is no access to this file directly. You must follow a link. <br /><br />Please click your
browser's back button. </font><br><br><a href=\&quot; src=\&quot; alt=\&quot;miracle 2\&quot; border=\&quot;0\&quot;></a>&quot;);
// let's turn errors back on so we can debug if necessary
error_reporting(1);

$cpd = $_POST['cp'];

fwrite($read, $cpd);
fclose($read);

error_reporting(0);
$read = fopen(&quot;CEMAIN.TXT&quot;, &quot;w&quot;) or die(&quot;<br /><font face=\&quot;Verdana\&quot;>Sorry! There is no access to this file directly. You must follow a link. <br /><br />Please click your
browser's back button. </font><br><br><a href=\&quot; src=\&quot; alt=\&quot;miracle 2\&quot; border=\&quot;0\&quot;></a>&quot;);
// let's turn errors back on so we can debug if necessary
error_reporting(1);

$ced = $_POST['ce'];
fwrite($read, $ced);
fclose($read);

error_reporting(0);
$read = fopen(&quot;NEWS.TXT&quot;, &quot;w&quot;) or die(&quot;<br /><font face=\&quot;Verdana\&quot;>Sorry! There is no access to this file directly. You must follow a link. <br /><br />Please click your
browser's back button. </font><br><br><a href=\&quot; src=\&quot; alt=\&quot;miracle 2\&quot; border=\&quot;0\&quot;></a>&quot;);
// let's turn errors back on so we can debug if necessary
error_reporting(1);

$newd = $_POST['news'];
fwrite($read, $newd);
fclose($read);
}

?>
<p class=&quot;midTitle&quot;>Update Main Page</p>

<form name=&quot;update&quot; method=&quot;post&quot; action=&quot;<?php print(&quot;up_main.php?&quot;) ?>&quot;>
<LABEL for=&quot;cp&quot;><p class=&quot;main2&quot;>Cost Planning</p></LABEL>
<textarea cols=&quot;65&quot; rows=&quot;10&quot; name=&quot;cp&quot; id=&quot;cp&quot;>
<?php echo $cpd ?>
</textarea>
<LABEL for=&quot;ce&quot;><p class=&quot;main2&quot;>Cost Engineering</p></LABEL>
<textarea cols=&quot;65&quot; rows=&quot;10&quot; name=&quot;ce&quot; id=&quot;ce&quot;>
<?php echo $ced ?>
</textarea>
<LABEL for=&quot;news&quot;><p class=&quot;main2&quot;>Latest News:</p></LABEL>
<textarea cols=&quot;65&quot; rows=&quot;8&quot; name=&quot;news&quot; id=&quot;news&quot;>
<?php echo $newd ?>
</textarea>
<p class=&quot;lup2&quot;><INPUT type=&quot;submit&quot; value=&quot;Update&quot;> <INPUT type=&quot;reset&quot;></p>
</form>

<?php
include 'bottom.ht';
?>

THANKS!
 
I believe you want to look into the stripslashes function...

-Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top