Forum Moderators: coopster

Message Too Old, No Replies

How do I fix the \" ?

         

Emperor

5:53 am on Apr 9, 2005 (gmt 0)

10+ Year Member



Hi guys,

When someone submits a form I take the TEXTAREA data and send it as the message body in an email.

But this: " comes out like this: \"

It's pretty annoying.

Thanks.

larryhatch

6:39 am on Apr 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



IF you are saying that an ordinary quotation mark ( " )
comes out as backslash-quote ( \" ) I might have a reason.

In C-language (Borland version at least) I have to put \" in any string
to print out the quotation mark only.

Reason is that text strings are themselves delimited by quote marks.
Without this device, quote within a string will make the string
terminate early, the rest interpreted as junk. Probably won't compile at all.

Java and other languages are VERY C-like. I would start looking there. - Larry

peewhy

7:19 am on Apr 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I also get this, try cutting the text, paste and edit in Word and paste it back ... I'm pretty sure that's what I did, and it worked.

dreamcatcher

9:19 am on Apr 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can you not just use stripslashes?

$message = $_POST['message'];

echo stripslashes($message);

dc

Emperor

5:23 pm on Apr 9, 2005 (gmt 0)

10+ Year Member



Hi guys,

Yeah, I know what the backslash is used for (Emperor knows C(++) too)

It just seemed odd that PHP was actually including the backslash as a seperate character rather than an escape sequence.

I'll try the stripslashes() function, I think that will do the trick.

Thanks.

tata668

1:01 am on Apr 10, 2005 (gmt 0)

10+ Year Member



I always remove the slashes.


function magicQuotesRemove(&$array)
{
if(!get_magic_quotes_gpc())
{
return;
}
foreach($array as $key => $elem)
{
if(is_array($elem))
{
magicQuotesRemove($elem);
}
else
{
$array[$key] = stripslashes($elem);
}
}
}

magicQuotesRemove($_GET);
magicQuotesRemove($_COOKIE);
magicQuotesRemove($_POST);

But if you use this, be sure to always use mysql_real_escape_string() (or a similar function for your favorite database ) before any database query.

irunsoft

1:19 am on Apr 10, 2005 (gmt 0)

10+ Year Member



As dreamcatcher said, you just have to stripslashes before sending your email

$msg = stripslashes($_POST['message']);

then send your $msg variable.

That it.