JSHINER Posted October 14, 2008 Share Posted October 14, 2008 $var = "The length is 5' x 2" and blah blah"; <input type="text" name="textBox" value="<?php echo $var; ?>"> In the <input> this cuts off at the ' if I do value='' and the " if I do value ="" and at either if I just do value= How do I get around this? Quote Link to comment https://forums.phpfreaks.com/topic/128403-solved-question-about-form-fields/ Share on other sites More sharing options...
KevinM1 Posted October 14, 2008 Share Posted October 14, 2008 $var = "The length is 5' x 2" and blah blah"; <input type="text" name="textBox" value="<?php echo $var; ?>"> In the <input> this cuts off at the ' if I do value='' and the " if I do value ="" and at either if I just do value= How do I get around this? You need to escape the quote that would otherwise cause the string to terminate: $var = "The length is 5' x 2\" and blah blah blah"; Quote Link to comment https://forums.phpfreaks.com/topic/128403-solved-question-about-form-fields/#findComment-665291 Share on other sites More sharing options...
JSHINER Posted October 14, 2008 Author Share Posted October 14, 2008 It's not the string that's terminating it's the <input> field. Quote Link to comment https://forums.phpfreaks.com/topic/128403-solved-question-about-form-fields/#findComment-665292 Share on other sites More sharing options...
Maq Posted October 14, 2008 Share Posted October 14, 2008 It's not the string that's terminating it's the field. Nightlsyr is right. The $var is in the field and has a " that needs to be escaped otherwise is terminates the input field. Quote Link to comment https://forums.phpfreaks.com/topic/128403-solved-question-about-form-fields/#findComment-665293 Share on other sites More sharing options...
Zhadus Posted October 14, 2008 Share Posted October 14, 2008 It is the input field, it's not actually a PHP related question - it's straight HTML. Don't you just LOVE HTML? By the way, here is a quick fix, use the HTML code for the double quotation: $var = "The length is 5' x 2" and blah blah"; It will output correctly for you and show up right, just a pain to work with. EDIT: " might work in place of " and a bit easier to use. Quote Link to comment https://forums.phpfreaks.com/topic/128403-solved-question-about-form-fields/#findComment-665296 Share on other sites More sharing options...
Maq Posted October 14, 2008 Share Posted October 14, 2008 Don't you just LOVE HTML? no Quote Link to comment https://forums.phpfreaks.com/topic/128403-solved-question-about-form-fields/#findComment-665300 Share on other sites More sharing options...
PFMaBiSmAd Posted October 14, 2008 Share Posted October 14, 2008 To put characters that have meaning in HTML into form field value parameters, you need to convert the special characters to HTML entities so that they are not operated on by the browser when it renders the page - http://us3.php.net/htmlentities Quote Link to comment https://forums.phpfreaks.com/topic/128403-solved-question-about-form-fields/#findComment-665301 Share on other sites More sharing options...
JSHINER Posted October 14, 2008 Author Share Posted October 14, 2008 I hate HTML But, that fixed it. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/128403-solved-question-about-form-fields/#findComment-665302 Share on other sites More sharing options...
kenrbnsn Posted October 14, 2008 Share Posted October 14, 2008 Here's where you want to use the htmlentities() function: <?php $var = "The length is 5' x 2\" and blah blah"; ?> <input type="text" name="textBox" value="<?php echo htmlentities($var, ENT_QUOTES); ?>"> Ken Quote Link to comment https://forums.phpfreaks.com/topic/128403-solved-question-about-form-fields/#findComment-665303 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.