473,857 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

posting/encode issue

I have a string in a select list.

value="Chadwick ’s"

after posting it's changed automatically

to

Chadwick's

How can I stop this?
Jul 17 '05 #1
3 1855

"chris" <ch***@bemail.o rg> wrote in message
news:d5******** *************** ***@posting.goo gle.com...
I have a string in a select list.

value="Chadwick &rsquo;s"

after posting it's changed automatically

to

Chadwick's

How can I stop this?


Run it through htmlspecialchar s() first and it will turn the & into &amp;
first, so you get "Chadwick&amp;r squo;s" in the value field, which looks
like "Chadwick&rsquo ;s" in the page.

Garp
Jul 17 '05 #2
I'm not gonna show it on a page. It's going to the database. Isn't
there a way to make PHP from messing with the variable?

Run it through htmlspecialchar s() first and it will turn the & into &amp;
first, so you get "Chadwick&amp;r squo;s" in the value field, which looks
like "Chadwick&rsquo ;s" in the page.

Garp

Jul 17 '05 #3
[top-post fixed]

"chris" <ch***@bemail.o rg> wrote in message
news:d5******** *************** **@posting.goog le.com...
Run it through htmlspecialchar s() first and it will turn the & into &amp; first, so you get "Chadwick&amp;r squo;s" in the value field, which looks
like "Chadwick&rsquo ;s" in the page.

Garp

I'm not gonna show it on a page. It's going to the database. Isn't
there a way to make PHP from messing with the variable?


PHP isn't messing with anything, that's HTTP doing that. Let me check what
you wanted to fix - you have the correct &-escaped string in the HTML so
it's going to be visible properly in the listbox, and when you select it and
get the results, the value of the select control is going to come back
unaltered. You want to store it in the database in real - i.e. not
&-escaped - format?

The help for htmlspecialchar s() gives this handy function for doing that,
but remember to handle quotes so that your SQL still works:

function htmldecode($enc oded) {
return
strtr($encoded, array_flip(get_ html_translatio n_table(HTML_EN TITIES)));
}

Personally, I store all my strings in the database in &-escaped format and
search strings get the htmlspecialchar s() treatment first.

HTH
Garp
Jul 17 '05 #4

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

Similar topics

5
4123
by: Scott Matthews | last post by:
I've recently come upon an odd Javascript (and/or browser) behavior, and after hunting around the Web I still can't seem to find an answer. Specifically, I have noticed that the Javascript encode() function behaves differently if a codepage has been set. For example: <script> document.write(escape('')); (note: that should be five accented characters)
4
4929
by: Newbie | last post by:
How would I modify this form to encode *all* the characters in the 'source' textarea to the '%xx' format & place result code into the 'output' textarea? (cross browser compatable) Any help is appreciated. Regards.
3
2677
by: Peter | last post by:
Hi, I try to make up a javascript string which contains numeric numbers in any positions. For example, I want to make a string: secretcode, where secretcode.charAt(0)==(-21), secretcode.charAt(5)==(-14). Is there any way to accomplish this task? Thanks in advance, Peter
0
1464
by: tkcheng | last post by:
Helllo, For security reason, we are changing our form submission coding with HTML encode on all the text fields to block the SQL injection. However, we encounter a problem on double byte character (we will input english and chinese character into the fields). If we input double byte character into the HTML encode fields and save to SQL database (our IIS server locale is in English language), the data will be corrupted. Could anyone...
4
7584
by: Darrel | last post by:
How does HTML.encode work? I'm trying to save text in a hidden form field into a SQL DB. The tedt is HTML (from a WYSIWYG editor...X-standard). One problem I have is that stray apostrophe's in the HTML text are throwing a SQL error. Html.encode doesn't seem to do anything with these, eh? Secondly, does HTMLencode also encode already encoded items?
6
6854
by: Scirious | last post by:
People, many of you may not know what yEnc is. To simplify, it is a methode to encode binary files very used in Usenet because it creates an overhead of only 2% when compare to 33%-40% of overhead created by other methos such as UUencode, base64... However, every code example I so was in C and using unsigned numbers. Actually, I've found one example in Java, but just for decode, not for encode. Are there anyone who knows how to help me?...
6
2342
by: 7stud | last post by:
s1 = "hello" s2 = s1.encode("utf-8") s1 = "an accented 'e': \xc3\xa9" s2 = s1.encode("utf-8") The last line produces the error: --- Traceback (most recent call last):
13
3701
by: mario | last post by:
Hello! i stumbled on this situation, that is if I decode some string, below just the empty string, using the mcbs encoding, it succeeds, but if I try to encode it back with the same encoding it surprisingly fails with a LookupError. This seems like something to be corrected? $ python Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04) on darwin
1
5787
by: anonymous | last post by:
1 Objective to write little programs to help me learn German. See code after numbered comments. //Thanks in advance for any direction or suggestions. tk 2 Want keyboard answer input, for example: answer_str = raw_input(' Enter answer ') Herr
0
9923
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9767
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10807
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10394
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7939
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 presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7104
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5774
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5967
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4592
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.