darkhappy Posted May 12, 2008 Share Posted May 12, 2008 I am getting an error when processing this code - could anyone give me the proper syntax/puntuation for this? <?php while ($a = mysql_fetch_array($approvals)) { if(isset($_POST['{$a['approvals']}'])) { $sheetid = $_POST['{$a['approvals']}']; } } ?> Link to comment https://forums.phpfreaks.com/topic/105192-variable-variables/ Share on other sites More sharing options...
dezkit Posted May 12, 2008 Share Posted May 12, 2008 <?php while ($a = mysql_fetch_array($approvals)) { if(isset($_POST['{$a["approvals"]}'])) { $sheetid = $_POST['{$a["approvals"]}']; } } ?> Link to comment https://forums.phpfreaks.com/topic/105192-variable-variables/#findComment-538633 Share on other sites More sharing options...
btherl Posted May 12, 2008 Share Posted May 12, 2008 Try this: <?php while ($a = mysql_fetch_array($approvals)) { if(isset($_POST[$a['approvals']])) { $sheetid = $_POST[$a['approvals']]; } } ?> The syntax for how you were trying to do it is like this: $val = "{$a['approvals']}"; Link to comment https://forums.phpfreaks.com/topic/105192-variable-variables/#findComment-538635 Share on other sites More sharing options...
darkhappy Posted May 12, 2008 Author Share Posted May 12, 2008 i will have to try that next time... instead i tweaked this function to pull the key out of the variable once it is posted. lots of work for a 1 little number hehe! <?php function get_sheet() { $context = '_POST'; global $$context; if(isset($$context)) { foreach($$context as $k => $v) { $sheetid = $k; } } } get_sheet(); ?> Link to comment https://forums.phpfreaks.com/topic/105192-variable-variables/#findComment-538641 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.