Quotes from Db into textfield

This is a discussion on Quotes from Db into textfield within the PHP Language forums, part of the PHP Programming Forums category; Hi there, i have a problem of wich i doubt it can be solved properly: If i call a text ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-01-2006
frizzle
 
Posts: n/a
Default Quotes from Db into textfield

Hi there,

i have a problem of wich i doubt it can be solved properly:
If i call a text from a (mySQL) database, and want to echo it into a
textfield (e.g. in a form) i experience the following problem (wich
makes sense, but wich i can't solve):

Imagine the following:
>> $db_string = 'The speech started as following: "Ladies and Gentlemen!".';


Source php:
>> <input name="textfield" type="text" value="<?php echo $db_string; ?>">


Source html:
>> <input name="textfield" type="text" value="The speech started as following: "Ladies and Gentlemen!".">


Wich only displays on the site:
>> The speech started as following:


Makes sense to me, but i cannot figure out how to solve it ...
(escaping with \" makes the backslash the last char)

Frizzle.

Reply With Quote
  #2 (permalink)  
Old 03-01-2006
Michael Fesser
 
Posts: n/a
Default Re: Quotes from Db into textfield

..oO(frizzle)

>i have a problem of wich i doubt it can be solved properly:
>If i call a text from a (mySQL) database, and want to echo it into a
>textfield (e.g. in a form) i experience the following problem (wich
>makes sense, but wich i can't solve):


www.php.net/htmlspecialchars

Micha
Reply With Quote
  #3 (permalink)  
Old 03-02-2006
frizzle
 
Posts: n/a
Default Re: Quotes from Db into textfield

Michael Fesser wrote:
> .oO(frizzle)
>
> >i have a problem of wich i doubt it can be solved properly:
> >If i call a text from a (mySQL) database, and want to echo it into a
> >textfield (e.g. in a form) i experience the following problem (wich
> >makes sense, but wich i can't solve):

>
> www.php.net/htmlspecialchars
>
> Micha


OK, i get what you mean, but i had already thought of that, but kind of
immediately faced the following problem: What if someone writes a
HTML-tutorial, and uses

&quot;

as a text, or even

"&quot;"

which would become

"""

So i believe this isn't the solution yet ... ( ? )

Frizzle.

Reply With Quote
  #4 (permalink)  
Old 03-02-2006
Michael Fesser
 
Posts: n/a
Default Re: Quotes from Db into textfield

..oO(frizzle)

>OK, i get what you mean, but i had already thought of that, but kind of
>immediately faced the following problem: What if someone writes a
>HTML-tutorial, and uses
>
>&quot;
>
>as a text, or even


This would become

&amp;quot;

>"&quot;"
>
>which would become
>
>"""


It would become

&quot;&amp;quot;&quot;

Micha
Reply With Quote
  #5 (permalink)  
Old 03-05-2006
frizzle
 
Posts: n/a
Default Re: Quotes from Db into textfield


Michael Fesser wrote:
> .oO(frizzle)
>
> >OK, i get what you mean, but i had already thought of that, but kind of
> >immediately faced the following problem: What if someone writes a
> >HTML-tutorial, and uses
> >
> >&quot;
> >
> >as a text, or even

>
> This would become
>
> &amp;quot;
>
> >"&quot;"
> >
> >which would become
> >
> >"""

>
> It would become
>
> &quot;&amp;quot;&quot;
>
> Micha


Ok, i get this, but if i call the text from the DB and put it into a
field:
from the db (raw) : "
into html textfield : ... value="&quot;" ...

It should display correctly, but what i meant, if a person types
another
quote into the field, so both are original quotes, things get messed
up,
because there is a html quote in it, and a real one.

I could use html_entities_decode, but this would also mess up the html-
tutorial characters ...

Frizzle.

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 12:10 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0