Re: Converting ampersand in QuickForm
| From: | fluidliqatyahoodotcom | Date: | Tue, 08 Mar 2005 02:38:58 +0000 |
| Subject: | Re: Converting ampersand in QuickForm | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-17919@lists.php.net to get a copy of this message | ||
Ohh...I finally get what you mean now. I have to set the charset in the header to the language I
want to input inorder for PHP to insert the raw characters into the database. Otherwise, if my
charset is the default iso charset, it will convert the characters into html entities and insert the
entities into the database. You was what you meant right?
This is the first time I am using PEAR. Usual forms insert into database doesn't convert the
raw text into html entities. PEAR does. Like what you said, it is for a purpose.
Thanks a lot. :)
Justin Patrin <papercrane@gmail.com> wrote:
On Sun, 6 Mar 2005 00:30:57 -0800 (PST), fluidliqatyahoodotcom
wrote:
> So i have something like this...
>
> require_once "HTML/QuickForm.php";
> $form = new HTML_QuickForm("form");
> $form->addElement("text", "txtName", "Enter: ",
> array("value" => "&");
> $form->display();
>
> Now yes, the value of the text element is an ampersand "&" in there. But the HTML
> is converted to its entities &
> Is there a way to have its HTML of the ampersand to be in its own character, "&",
> rather than "&"?
> I need this for a purpose.
>
How many times do you need to hear this? This is done *for a purpose*.
QF assumes that any strings you give it are the actual strings you
want displayed and then converts the entities *as it should*. A single
ampersand is technically incorrect in an HTML document.
I realize that your text already had entities in it (#12345;) but
this should not be. You should be making it so that your DB does not
have these entities. It should have the raw text. How are these
entires getting into the DB? If it's a script you wrote, what charset
is set on that page? Have you tried changing it?
How about using chr to convert these? I have not tested this, but:
$str = preg_replace('/&#(\d+);/e', 'chr(\1)', $str);
--
Justin Patrin
---------------------------------
Celebrate Yahoo!'s 10th Birthday!
Yahoo! Netrospective: 100 Moments of the Web