dmaru09 Posted July 2, 2009 Share Posted July 2, 2009 hey guys, looking to put a $ variable inside a session variable. heres the code while($duedatesformat != '0') { $seperators = array(",", ".", "-", ":", "\;", "_", "`", "\\"); $dtd1=str_replace($seperators, "/", $_SESSION['due_date_'.$duedatesformat].'); $arrd1=split("/",$dtd1); $mmd1=$arrd1[0]; $ddd1=$arrd1[1]; $yyd1=$arrd1[2]; $formattedDueDate1 = date("m/d/Y", mktime(0,0,0, $mmd1, $ddd1, $yyd1)); # ~~~~~ Checks for a valid date ~~~~~# if(!checkdate($mmd1,$ddd1,$yyd1)) { $_SESSION['e_due_date_'.$duedatesformat].' = "Invalid date. Please re-enter your date."; $error = 1; echo '<meta HTTP-EQUIV="REFRESH" content="0; url=InsertMC.php">'; } $duedatesformat = $duedatesformat -1; } all of that works so far except for: $_SESSION['e_due_date_'.$duedatesformat].' = "Invalid date. Please re-enter your date."; I cannot figure out the correct format here. Anyone know offhand? Parse error: syntax error, unexpected T_STRING in /export/home/oracle/itcrapp/ITInvoice/InsertMC.php on line 296 Thats my error btw. Link to comment https://forums.phpfreaks.com/topic/164532-variable-inside-session-variable/ Share on other sites More sharing options...
kenrbnsn Posted July 2, 2009 Share Posted July 2, 2009 Too many "." and "'", write it as <?php $_SESSION['e_due_date_'.$duedatesformat] = "Invalid date. Please re-enter your date."; ?> Ken Link to comment https://forums.phpfreaks.com/topic/164532-variable-inside-session-variable/#findComment-867824 Share on other sites More sharing options...
dmaru09 Posted July 2, 2009 Author Share Posted July 2, 2009 Too many "." and "'", write it as <?php $_SESSION['e_due_date_'.$duedatesformat] = "Invalid date. Please re-enter your date."; ?> Ken Tried this already, still doesn't work. Link to comment https://forums.phpfreaks.com/topic/164532-variable-inside-session-variable/#findComment-867827 Share on other sites More sharing options...
dmaru09 Posted July 2, 2009 Author Share Posted July 2, 2009 Too many "." and "'", write it as <?php $_SESSION['e_due_date_'.$duedatesformat] = "Invalid date. Please re-enter your date."; ?> Ken It appears that may have worked, but that this other line may be the cause of the problem. $dtd1=str_replace($seperators, "/", $_SESSION['due_date_'.$duedatesformat].'); Any suggestions? Thank you btw. Link to comment https://forums.phpfreaks.com/topic/164532-variable-inside-session-variable/#findComment-867829 Share on other sites More sharing options...
PFMaBiSmAd Posted July 2, 2009 Share Posted July 2, 2009 You should probably be using a 2-dimensional array instead of a sequence of dynamically named, composite, array indexes - $_SESSION['due_date'][$duedatesformat] and $_SESSION['e_due_date'][$duedatesformat] Link to comment https://forums.phpfreaks.com/topic/164532-variable-inside-session-variable/#findComment-867839 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.