princeofpersia Posted January 12, 2012 Share Posted January 12, 2012 Hi guys, Im trying to insert a session into a html select <option> but never done it before, can you help me to see how? I have a code here but there is a syntax error if($_SESSION['name']){ echo "<option value=$_SESSION['name']>$_SESSION['name']</option>"; } Thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/254879-syntax-error/ Share on other sites More sharing options...
dharmeshpat Posted January 12, 2012 Share Posted January 12, 2012 if($_SESSION['name']){ echo "<option value='".$_SESSION['name']."'>".$_SESSION['name']."</option>"; } Quote Link to comment https://forums.phpfreaks.com/topic/254879-syntax-error/#findComment-1306863 Share on other sites More sharing options...
Muddy_Funster Posted January 12, 2012 Share Posted January 12, 2012 try using isset and {} :- if(isset($_SESSION['name'])){ echo "<option value={$_SESSION['name']}>{$_SESSION['name']}</option>"; } Quote Link to comment https://forums.phpfreaks.com/topic/254879-syntax-error/#findComment-1306865 Share on other sites More sharing options...
awjudd Posted January 12, 2012 Share Posted January 12, 2012 Please Note: it is extremely helpful if you provide the actual error you are getting. ~awjudd Quote Link to comment https://forums.phpfreaks.com/topic/254879-syntax-error/#findComment-1306866 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.