Page 1 of 1

Where to implement stripslashes?

Posted: Wed Mar 02, 2005 12:56 pm
by Fusioned
Below is the code for a little posting program I did. However of course, when the ' get's in there, the slashes come out. Where and how would I implement stripslashes()? Thanks. Im pretty bad at this stuff. :)

Code: Select all

<?

///WRITING TO THE FILE LEDGER.TXT


function WriteToFile ($Description, $Image, $EmailAddress, $FullName) &#123;

$TheFile = "ledger.txt";

$CurrentDate = date("l F j, Y");

$Open = fopen ($TheFile, "a");

if ($Open) &#123;

fwrite ($Open,
	"<table><tr><td width='400' valign='top'><font size='2' color='#333333'><b>$CurrentDate</b><BR>$Description</font></td></tr><tr><td width='400' valign='top'><font size='2' color='#333333'><u>$FullName</u> | <b><a href='mailto:$EmailAddress'>$EmailAddress</a></b><BR><BR>
	</font></td></tr></table><BR>\n");
		
	
		trim ($Description);
		
		fclose ($Open);
		
		$Worked = TRUE;
		
		&#125; else &#123;
		
		$Worked = FALSE;
		
		&#125;
		
		return $Worked;
		
		&#125; 
		
		if(isset($Array&#1111;'EmailAddress']))
		&#123;
		


$CallFunction = WriteToFile
($Array&#1111;"Description"], $Array&#1111;"Image"], $Array&#1111;"EmailAddress"], $Array&#1111;"FullName"]);



&#125;



if ($CallFunction)  &#123;

print ("\n");

 &#125; else &#123;
 
 print ("\n");
 
 &#125;
 ?>

Posted: Wed Mar 02, 2005 1:28 pm
by John Cartwright
wherever you want to print your unslashed output.

For example

Code: Select all

echo stripslashes($varname);
In your case, your going to have to escape quotes.. so it will look like

Code: Select all

echo "This is some text so ".stripslashes($varname)." and your good";

Posted: Wed Mar 02, 2005 2:08 pm
by smpdawg
Just an observation. You should shy away from <? as some servers may not allow the use of short tags. Use <?php and you will always be covered.

Posted: Wed Mar 02, 2005 4:56 pm
by Fusioned
Thanks. I usually do use ?php but I am lazy haha.

So you think I should do this?
Say I want to print a variable named $description out without slashes. Would I do this?

Code: Select all

"My name is Vince. I though that the movie was 'stripslashes($description)'.";

Posted: Wed Mar 02, 2005 4:58 pm
by smpdawg
Like this

Code: Select all

echo "My name is Vince. I though that the movie was '" . stripslashes($description) . "'.";

Posted: Wed Mar 02, 2005 5:01 pm
by Fusioned
Aha! It worked perfectly! Thank you so much guys.