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 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. 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... 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? 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 ... 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
Archived
This topic is now archived and is closed to further replies.