473,785 Members | 2,297 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Special character (") in textfield

m6s
55 New Member
I have a value saved in mysql table like this:
{"name":"poppy" }
When I need to place another symbol " for example to name it "Cheeps and Potatoes", it's saved in mysql table with \". Up to now all ok. This seems to me ok. Escape character added.

I restore the value twice, now...
Into a textfield in order to edit the value of name.
And also as plain value in order to view it.
As plain value, I can see the text "Cheaps and Potatoes"
but in textfield, I see void! Why ?!
I use php 5.2, mysql 5.1, and plain html.
Oct 4 '10 #1
6 1940
dlite922
1,584 Recognized Expert Top Contributor
show us the section of the code that has a problem. I'm having a hard time dissecting your question.


Dan
Oct 4 '10 #2
kovik
1,044 Recognized Expert Top Contributor
No idea what OP is asking, but make sure that magic_quotes are off are that you are properly escaping data before entering it into your database.
Oct 5 '10 #3
m6s
55 New Member
Expand|Select|Wrap|Line Numbers
  1. public static function textfield($name, $value, $edit) {
  2.         if ($edit) {
  3.             print $value . "<BR/>";
  4.             $str2 = str_replace('"', "'", $value);
  5.             $str2 = ereg_replace( chr(ord("'")), "\"", $str2);
  6.             print $str2;
  7.             print( "<input id = \"$name\" name=\"$name\" type=\"text\" size=\"60px\" value=\"$str2\"/>");
  8.         } else {
  9.             print( "$value");
  10.         }
  11.     }
  12.  
Above is the section I am talking about.

What is says is: If you got to edit the value, render an input of type=text. ( Please omit the lines that do str_replace as these lines with the next ereg_replace, was just my try-and-error. )

When I have a value like "Cheaps" and "Dales" for example, it is rendered quite well when NOT in edit state. But in edit state, I lose everything after (").
If I have a value, plain: Cheaps and Dales, everything is just fine.
Oct 5 '10 #4
kovik
1,044 Recognized Expert Top Contributor
That function is... awkward. You replace quotation marks with apostrophes, and then you replace the apostrophes with quotation marks...

Get rid of the str_replace and the ereg_replace, and use htmlspecialchar s() instead.
Oct 5 '10 #5
m6s
55 New Member
O-M-G! Was that awful simple? :-)
Sure hadn't any clue about this function! Thank you very much Kovin!

For the record, I tried to make replacements in order to manipulate the symbols...And really it makes me a bit worry, why didn't catch the trick....but the thing now is that it works!
Thank you!
Oct 5 '10 #6
kovik
1,044 Recognized Expert Top Contributor
No problem.

What you were doing was escaping the quotation marks. That works in strings (such as inputting data to the database), but not in HTML. The htmlspecialchar s() function converts them to HTML entities (i.e. &quot;), which is like escaping th quotes for HTML.
Oct 5 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
432
by: Norman Uhlenkott | last post by:
I would like to be able to put in special character inside an xml data string (#, <, >, &). when it trys to parses out the XML String it errors out strXML = "<?xml version='1.0'?>" & vbCRLF strXML = strXML + "<WO_Step>" & vbCRLF strXML = strXML + "<Test>Test Special Characters #, %, &, <, > </Test> strXML = strXML + "</WO_Step>"
0
899
by: Ray | last post by:
In vb.net response.write ("""haha""") this will return a "haha In c# the same code will return an error How do I correct the error in c# Actually, I have a stringbuilder and appending the <a href='#' onclick="window.open('/yaya/sali.aspx?images1/a1.jpg', 'garbage', 'width=800,height=600,top=100,toolbar=0,menubar=0,scrollbar=1,resizable=0')"><img src='/fala/imgd/a1.jpg' width=80px height=80px></a Please help
50
4356
by: The Bicycling Guitarist | last post by:
A browser conforming to HTML 4.0 is required to recognize &#number; notations. If I use XHTML 1.0 and charset UTF-8 though, does &eacute; have as much support as é ? Sometimes when I run the TIDY utility on my code, it replaces my character notations with weird looking things I don't recognize. Also, when I converted to UTF-8 from ISO-8859-1, I discovered many special characters
2
2291
by: Ozer | last post by:
Hi friends, I wanna ask something. I use javascript menu on my user interface. And the js files contains special(turkish) character. I need to use codepage=1254 attribute in my @Page tag. If i don't use it. Javascript menu and functions fail. But if i add this atrribute, after i posted the form, all of the special(turkish) characters becomes deleted. Thanks for any help. Bye.
1
4575
by: sonald | last post by:
Dear All, I am working on a module that validates the provided CSV data in a text format, which must be in a predefined format. We check for the : 1. Number of fields provided in the text file, 2. Text checks for max. length of the field & whether the field is mandatory or optional Example:
2
5583
by: Diilb | last post by:
I am using DOM to create an rss feed. The problem I am running into is "special characters" such as é è ç. If I try adding them to the XML as character data (CData), DOM chokes and throws out errors. If I do a search and replace on the characters changing them to HTML entities instead of using CDATA, DOM chokes up again. If I do a combination of both (search and replace then add as Character Data) it does not choke, but the RSS...
3
14678
by: jeyabarani | last post by:
Hi guys, I want to check whether the user has entered any special characters in a text box. If the user enters, i want to display an alert message stating that he cant enter a special character (like Ç). I have written a code wherein i am specifying the list of characters that are not allowed. It would be better if i can give a list of characters that are allowed instead of list of characters that are not allowed. And check whether...
1
2434
kaleeswaran
by: kaleeswaran | last post by:
Hi! i am handling password generation module..... i need to force the user enter the special character in their password thing.so i need to handle the special character.so how do i check if the user enter the special character or not?... waiting for ur's response.... thank you, kaleeswaran
1
1533
by: Ragavendran | last post by:
Hi, I am using this method for search: Query =org.apache.lucene.queryParser.QueryParser.parse(String arg0) throws ParseException Hits = org.apache.lucene.search.Searcher.search(Query query, Sort sort) throws IOException Problem : I cant able to search the word. If the word contain special character like , %BF It just taken that special character a empty space and search the remaining character
1
1576
by: dinesh1985singh | last post by:
Hello Everyone, In my database I found few special character,these special character were get stored even after using proper function for striping out these character,like mysql_real_escape function in php. I found these characters in my database Sipsâ„¢ should be Sips™ There’s should be There’s Rosé: should be Rosé: ’ should be '
0
9647
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9489
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,...
0
10162
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9959
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
7509
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
6744
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
5528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4061
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
2
3665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.