mubashir Posted October 26, 2007 Share Posted October 26, 2007 i use session variables to store values submitted by the form for later retrieval.. but once i try to retrieve the values they get truncated where ever the white space is encoutered... e.g. if i submit the value as "blood sample".. n store it in session variabl.. once i try to retrieve the value it shows "blood" only ... anything after the white space is ingnored or truncated... code snippet is like this ... //storing the values... $tname=$_POST['tstname']; $_SESSION['testname']=$tname; .. //retrieve values... <input type ="text" name ="tstname" value =<?php echo $_SESSION['testname']; ?>> . . any body knows wats the problem ... thankx Quote Link to comment https://forums.phpfreaks.com/topic/74851-solved-white-space-creating-problems-in-session-variables/ Share on other sites More sharing options...
GingerRobot Posted October 26, 2007 Share Posted October 26, 2007 Actually, the whole string is still inside your session variable its an HTML problem. Try: <input type ="text" name ="tstname" value ="<?php echo htmlentities($_SESSION['testname']); ?>"> Note the double quotes. Without surrounding your value in quotes, how is a browser supposed to know when the value ends and the next property begins? Hence why it makes an educated guess, and uses spaces. Also, ive added the htmlentities() function there - otherwse you'll run into issues if your variable contains double quotes. Quote Link to comment https://forums.phpfreaks.com/topic/74851-solved-white-space-creating-problems-in-session-variables/#findComment-378450 Share on other sites More sharing options...
mubashir Posted October 26, 2007 Author Share Posted October 26, 2007 i tried using double quotes also but didnt worked .... even if i try to print outside form by simply using echo "$_SESSION['testname']"; its still printing truncated values... Quote Link to comment https://forums.phpfreaks.com/topic/74851-solved-white-space-creating-problems-in-session-variables/#findComment-378453 Share on other sites More sharing options...
GingerRobot Posted October 26, 2007 Share Posted October 26, 2007 Bizarre. Can we see some more of the code you are using? Quote Link to comment https://forums.phpfreaks.com/topic/74851-solved-white-space-creating-problems-in-session-variables/#findComment-378456 Share on other sites More sharing options...
mubashir Posted October 26, 2007 Author Share Posted October 26, 2007 thankx guys ... it worked i was misusing the quotes .. still learning ... Quote Link to comment https://forums.phpfreaks.com/topic/74851-solved-white-space-creating-problems-in-session-variables/#findComment-378538 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.