FORUMS: list search recent posts

/' :'( Anoying problem

COW Forums : Web Design

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Dan Browne/' :'( Anoying problem
by on May 1, 2008 at 12:33:37 am

I have 2 sites going that I have just noticed a problem with. One has an email form where the user puts their email address, their name, and their comment, click submit and it sends the email to me. The other has a form where the user types in their text, clicks submit, that saves the text inputed into a text file, and somewhere else on the site, it pulls the text from that file and includes it in the site. The problem I am having is whenever someone uses a ' it saves/sends it like this /' so if someone writes "it's a lovely day", it appears like "it/'s a lovely day". How am I able to make it display as it should? Hope that's clear.
Cheers,
Dan

Dan Browne
Hawkes Bay, New Zealand
Cloud South Films
http://www.cloudsouthfilms.co.nz


Return to posts index

Curtis ThompsonRe: /' :'( Anoying problem
by on May 1, 2008 at 1:07:41 am

hello...

w/o knowing your scripting language, it's hard to be perfectly accurate, but this looks like php's old magic quotes issue - try this function:

http://us.php.net/stripslashes

hope that helps!

sitruc





Return to posts index

Dan BrowneRe: /' :'( Anoying problem
by on May 1, 2008 at 1:14:41 am

hey,
Yeah sorry, I was scripting in php. Thanks for that, just about to look at it now.
D

Dan Browne
Hawkes Bay, New Zealand
Cloud South Films
http://www.cloudsouthfilms.co.nz


Return to posts index


Dan BrowneRe: /' :'( Anoying problem
by on May 1, 2008 at 3:10:28 am

I couldnt work out from that page what to do to solve the problem. This is my code:
/On the page with the form/

$myFile = "../../text/mirrorstatement.txt";
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);
?>



Edit Text



<textarea name="contents" cols="100" rows="10" id="contents">
</textarea>



Back



/and on the post.php page/

session_start();
if(!session_is_registered(myusername)){
header("location:index.php");
}
?>

$contents=$_POST['contents'];
$handle = fopen('../../text/mirrorstatement.txt', 'w');
fwrite($handle, $contents);
fclose($handle);
?>

Success


 




Any help is greatly appreciated.
Cheers,
Dan

Dan Browne
Hawkes Bay, New Zealand
Cloud South Films
http://www.cloudsouthfilms.co.nz


Return to posts index

Curtis ThompsonRe: /' :'( Anoying problem
by on May 1, 2008 at 3:49:21 am

hello...

didn't see stripslashes in there, so not sure where you tried, but this line looks like a potential candidate:

$contents=$_POST['contents'];

so i'd make that:

$contents=stripslashes($_POST['contents']);

basically get rid of them in any variable you want to before you save it to the file and you should be ok...

sitruc




Return to posts index

Dan BrowneRe: /' :'( Anoying problem
by on May 1, 2008 at 4:36:37 am

awesome, works like a charm. Thank you :D

Dan Browne
Hawkes Bay, New Zealand
Cloud South Films
http://www.cloudsouthfilms.co.nz


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]