blkraven Posted January 12, 2009 Share Posted January 12, 2009 As many others I am new to this and am having a problem displaying data returned from a database table. The data contains a quote mark which I am pretty certain is my problem. The data returned is a product description such as - 14" bowl. When I display the field most of the time it displays ok. such as: <td><span class="style2"><?php echo "{$row['DESCRIPTION']}"; ?></span></td> Returns: 14" Bowl But when I try the following: <td colspan = "5"><input type="text" name="DESCRIPTION" value="<?php echo "{$row['DESCRIPTION']}"; ?>"id="DESCRIPTION" size="100" /></td> All I get returned is 14 It cuts it off at the quote. Can someone help with what I am doing wrong. Quote Link to comment https://forums.phpfreaks.com/topic/140586-solved-truncating-at-quotes/ Share on other sites More sharing options...
Rushyo Posted January 13, 2009 Share Posted January 13, 2009 An echo replaces a statement with whatever it returns... thus: <td colspan = "5"><input type="text" name="DESCRIPTION" value="<?php echo "{$row['DESCRIPTION']}"; ?>"id="DESCRIPTION" size="100" /></td> Will return: <td colspan = "5"><input type="text" name="DESCRIPTION" value="14""id="DESCRIPTION" size="100" /></td> Not terribly correct HTML. You should use encoded characters, see http://uk.php.net/html_entities. For example: $strDesc = html_entities($row['DESCRIPTION'], ENT_QUOTES); The ENT_QUOTES is important, otherwise quotes won't be converted Quote Link to comment https://forums.phpfreaks.com/topic/140586-solved-truncating-at-quotes/#findComment-735744 Share on other sites More sharing options...
blkraven Posted January 13, 2009 Author Share Posted January 13, 2009 Thank you very much. Once I changed the html_entities to htmlentities it worked great. Quote Link to comment https://forums.phpfreaks.com/topic/140586-solved-truncating-at-quotes/#findComment-736135 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.