473,398 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

escape charecters

Can anyone tell me ho to get certain charecters to be displayed.
When sending email with (') i get (\) instead. i.e.

This dosen't work becomes dosen\t

Is there some kind of escape key to get passed this please.

Jul 17 '05 #1
5 2331
Desmond wrote:
Can anyone tell me ho to get certain charecters to be displayed.
When sending email with (') i get (\) instead. i.e.

This dosen't work becomes dosen\t

Is there some kind of escape key to get passed this please.


How are the stings you're sending getting set. If the information is
coming from a form, you should use the function stripslashes() on the
input before sending.

If you are creating the strings yourself, you can surround strings
containing single quotes with double quotes and vice versa.

Example:

$str1 = "this string contains a single quote ' ";
$str2 = 'This string contains a double quote " ';
echo $str1.'<br>'.$str2."<br>\n";

Ken

Jul 17 '05 #2
Wha I am doing is using a html form for sending an Email the input box
may have a name
Paul O'Brien so the PHP line $name = $_POST["Name"]; end up in the
email as
Paul O\Brien replacing the the (') to (\) if i use stripslashes()
there are no slashes to strip

do i need a search and replace string.

Desmond.

Jul 17 '05 #3
Sorted. I don't know why this is happening but if I enter

Paul O'Brian in a html page and submit this to a PHP page it adds a (\)
giving me Paul O\'Brian

I have to use the following $name = str_replace("\\" ,"" , $name);
to correct it.

Why ?

Desmond.

Jul 17 '05 #4
Desmond wrote:
Wha I am doing is using a html form for sending an Email the input box
may have a name
Paul O'Brien so the PHP line $name = $_POST["Name"]; end up in the
email as
Paul O\Brien replacing the the (') to (\) if i use stripslashes()
there are no slashes to strip


Here's a sample program I just wrote:

<?
if (isset($_POST['submit'])) {
echo '$_POST array<pre>';
print_r($_POST);
echo '</pre>';
$name = stripslashes($_POST['name']);
echo 'You entered the name of <span style="font-weight:bold">' . $name
.. "</span><br>\n";
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<title>Test form</title>
</head>

<body>
<form method="post" action="<? echo $_SERVER['PHP_SELF']?>">
Name: <input type="text" style="width:50%" name="name"><br>
<input type="submit" name="submit" value="Send Data">
</form>
</body>
</html>

And here's the output:

$_POST array

Array
(
[name] => O\'Brian
[submit] => Send Data
)

You entered the name of O'Brian

Notice how the single quote is escaped in the input data, so when I
assign it to a variable I used stripslashes() to unescape it.

Compare this code to what you have (since you didn't post it) and see
if it differs. Then run this code to see what it produces.

Ken

Jul 17 '05 #5


Desmond wrote:
Sorted. I don't know why this is happening but if I enter

Paul O'Brian in a html page and submit this to a PHP page it adds a (\)
giving me Paul O\'Brian

I have to use the following $name = str_replace("\\" ,"" , $name);
to correct it.


That's because "Magic Quotes" are turned on. As I said before, use the
function stripslashes() to remove the escape character.

Ken

Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Paul | last post by:
I have an Access 2000 database with a form that is giving me some major headaches. When you open the form, it displays all records and allows editing, but has AllowAdditions set to False so that...
18
by: Steve Litvack | last post by:
Hello, I have built an XMLDocument object instance and I get the following string when I examine the InnerXml property: <?xml version=\"1.0\"?><ROOT><UserData UserID=\"2282\"><Tag1...
1
by: Alex Smith | last post by:
Hi friends, I want to read all charecters of pdf file using char array. Thanks, Alex.
1
by: Alex Smith | last post by:
Hi friends, I want to read all charecters of pdf file using char array. Thanks, Alex.
2
by: 28tommy | last post by:
Hello all, I know how to exclude 1 charecter from a compiled sequence of the re module- '', but if I want to exclude a word or a sequence as one unit (not as separate charecters) to be...
15
by: pkaeowic | last post by:
I am having a problem with the "escape" character \e. This code is in my Windows form KeyPress event. The compiler gives me "unrecognized escape sequence" even though this is documented in MSDN....
0
by: Vishal Dalsania | last post by:
Hello all, I have created an application in ASP.NET 2.0. When i run it from internet explorer the aspx page shows some garbage charecters in it. I tried looking in to the HTML source of the page...
131
by: Lawrence D'Oliveiro | last post by:
The "escape" function in the "cgi" module escapes characters with special meanings in HTML. The ones that need escaping are '<', '&' and '"'. However, cgi.escape only escapes the quote character if...
2
by: nityagopikrishnan | last post by:
how do we write a programme to find the frq of charecters of a string eg you are great output no of y=1 no of o=1 no of u=1 no of a=2 no of r=2 no of e =2 no of g=1
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.