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 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>"; } 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>"; } 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 Link to comment https://forums.phpfreaks.com/topic/254879-syntax-error/#findComment-1306866 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.