kts Posted September 24, 2008 Share Posted September 24, 2008 I am trying to retreive data with " and ' in the info ex. "24" 7'" (24ft 7in) I did the add slashes to add it to the database, but whats the best way of getting it into a text box without problems? input text Quote Link to comment https://forums.phpfreaks.com/topic/125640-need-help-retrieving-mysql-data-with-and-in-the-value/ Share on other sites More sharing options...
DarkWater Posted September 24, 2008 Share Posted September 24, 2008 You should have used mysql_real_escape_string() rather than addslashes(). Quote Link to comment https://forums.phpfreaks.com/topic/125640-need-help-retrieving-mysql-data-with-and-in-the-value/#findComment-649603 Share on other sites More sharing options...
phoenixx Posted September 24, 2008 Share Posted September 24, 2008 Use mysql_real_escape_string when inserting the data but use stripslashes just to be safe on output echo stripslashes($str); // WHERE $str is your variable name Quote Link to comment https://forums.phpfreaks.com/topic/125640-need-help-retrieving-mysql-data-with-and-in-the-value/#findComment-649609 Share on other sites More sharing options...
kts Posted September 24, 2008 Author Share Posted September 24, 2008 Ok tried that solution, but the problem isnt output normal, it is when i put it in a value of a text box it shows up stripped (24) instead of (24" 5') is there a specific way for input text? Quote Link to comment https://forums.phpfreaks.com/topic/125640-need-help-retrieving-mysql-data-with-and-in-the-value/#findComment-649613 Share on other sites More sharing options...
kts Posted September 24, 2008 Author Share Posted September 24, 2008 did not find the solution, but found an alternate route. It shows up fine in a textarea. Quote Link to comment https://forums.phpfreaks.com/topic/125640-need-help-retrieving-mysql-data-with-and-in-the-value/#findComment-649628 Share on other sites More sharing options...
DarkWater Posted September 24, 2008 Share Posted September 24, 2008 You need to use htmlentities($string, ENT_QUOTES) on ANY value going into an HTML attribute. I didn't know what you were talking about originally, otherwise I would have suggested the proper solution. Quote Link to comment https://forums.phpfreaks.com/topic/125640-need-help-retrieving-mysql-data-with-and-in-the-value/#findComment-649640 Share on other sites More sharing options...
wildteen88 Posted September 24, 2008 Share Posted September 24, 2008 did not find the solution, but found an alternate route. It shows up fine in a textarea. if it works with a textarea then it means before you was not coding your <input>'s correctly. The only way I see the problem you're having is if you don't wrap attribute values with quotes. Quote Link to comment https://forums.phpfreaks.com/topic/125640-need-help-retrieving-mysql-data-with-and-in-the-value/#findComment-649643 Share on other sites More sharing options...
DarkWater Posted September 24, 2008 Share Posted September 24, 2008 Actually wildteen, it was because he had " or ' inside of his value attribute, which screwed everything up. Quote Link to comment https://forums.phpfreaks.com/topic/125640-need-help-retrieving-mysql-data-with-and-in-the-value/#findComment-649651 Share on other sites More sharing options...
discomatt Posted September 24, 2008 Share Posted September 24, 2008 Actually wildteen, it was because he had " or ' inside of his value attribute, which screwed everything up. Indeed, and because textarea doesn't use attributes to populate itself, it worked. A quick look at the outputted source code would've made this clear. Quote Link to comment https://forums.phpfreaks.com/topic/125640-need-help-retrieving-mysql-data-with-and-in-the-value/#findComment-649675 Share on other sites More sharing options...
wildteen88 Posted September 24, 2008 Share Posted September 24, 2008 Actually wildteen, it was because he had " or ' inside of his value attribute, which screwed everything up. Woops, You're right. Ignore my post. Quote Link to comment https://forums.phpfreaks.com/topic/125640-need-help-retrieving-mysql-data-with-and-in-the-value/#findComment-649679 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.