Sounds very simple, but I'm kinda confused at the moment.
I have this DB object which includes some values that I want to output in an html form.
Simplified Problem:
$result is my db object and this is the html input where I want to output some text which can include double or single quotes.
<input class="someclass" name="desc" id="descID" type="text" value="<?=$result['desc'];?>" placeholder="<Description>" />
So if $result['desc'] contains text like this: 'Did you hear about "foobar"?'
everything after the first double quote gets cut off and ends up like this: 'Did you hear about '.
What i have tried already without success:
htmlspecialchars like this
value="<?=htmlspecialchars($result['desc']);?>"or like thisvalue="<?=htmlspecialchars($result['desc'], ENT_QUOTES);?>"addslashes
Note: My DB(mssql) saves the string properly. Only have the problems in my html.
I would be glad if you could help me out here. Thanks.
<?php $t = 'Did you hear about "foobar"?'; ?> <input class="someclass" name="desc" id="descID" type="text" value="<?= htmlspecialchars($t);?>" />work likes charm!!<?php $t = 'Did you hear about "foobar"?'; ?>. i tried<?php $t = $result['desc']; ?>and it didn't work