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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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. |
|
|||
|
..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 |
|
|||
|
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 " as a text, or even """ which would become """ So i believe this isn't the solution yet ... ( ? ) Frizzle. |
|
|||
|
..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 > >" > >as a text, or even This would become &quot; >""" > >which would become > >""" It would become "&quot;" Micha |
|
|||
|
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 > > > >" > > > >as a text, or even > > This would become > > &quot; > > >""" > > > >which would become > > > >""" > > It would become > > "&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=""" ... 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. |