PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Fusioned
Forum Commoner
Posts: 32 Joined: Tue Jan 18, 2005 10:43 pm
Location: Philadelphia, PA
Post
by Fusioned » Wed Mar 02, 2005 12:56 pm
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) {
$TheFile = "ledger.txt";
$CurrentDate = date("l F j, Y");
$Open = fopen ($TheFile, "a");
if ($Open) {
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;
} else {
$Worked = FALSE;
}
return $Worked;
}
if(isset($Arrayї'EmailAddress']))
{
$CallFunction = WriteToFile
($Arrayї"Description"], $Arrayї"Image"], $Arrayї"EmailAddress"], $Arrayї"FullName"]);
}
if ($CallFunction) {
print ("\n");
} else {
print ("\n");
}
?>
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Wed Mar 02, 2005 1:28 pm
wherever you want to print your unslashed output.
For example
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";
smpdawg
Forum Contributor
Posts: 292 Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:
Post
by smpdawg » Wed Mar 02, 2005 2:08 pm
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.
Fusioned
Forum Commoner
Posts: 32 Joined: Tue Jan 18, 2005 10:43 pm
Location: Philadelphia, PA
Post
by Fusioned » Wed Mar 02, 2005 4:56 pm
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)'.";
smpdawg
Forum Contributor
Posts: 292 Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:
Post
by smpdawg » Wed Mar 02, 2005 4:58 pm
Like this
Code: Select all
echo "My name is Vince. I though that the movie was '" . stripslashes($description) . "'.";
Fusioned
Forum Commoner
Posts: 32 Joined: Tue Jan 18, 2005 10:43 pm
Location: Philadelphia, PA
Post
by Fusioned » Wed Mar 02, 2005 5:01 pm
Aha! It worked perfectly! Thank you so much guys.