noobified Posted August 30, 2008 Share Posted August 30, 2008 im wondering if someone could have a look at this and point out what is wrong, it keeps giving the following notice PHP Notice: Undefined variable: themeName0 PHP Notice: Undefined variable: blockArrowColorTheme0 PHP Notice: Undefined variable: blockBackgroundImageTheme0 case "themeImageSubmit": for ($x = 0; $x <= $totalThemes; $x++) { $themeImageValues["themeName"][$x] = ${"themeName$x"}; $themeImageValues["${"themeName$x"}"]["blockArrowColor"] = ${"blockArrowColorTheme$x"}; $themeImageValues["${"themeName$x"}"]["blockBackgroundImage"] = ${"blockBackgroundImageTheme$x"}; } themeImageSubmit($themeImageValues, $totalThemes); break; Link to comment https://forums.phpfreaks.com/topic/121978-array-undefined-variables/ Share on other sites More sharing options...
phpretard Posted August 30, 2008 Share Posted August 30, 2008 Shot in the dark... $x=1 Link to comment https://forums.phpfreaks.com/topic/121978-array-undefined-variables/#findComment-629626 Share on other sites More sharing options...
phpretard Posted August 30, 2008 Share Posted August 30, 2008 Does this help? <?php for($i=0; $i<8; ++$i) { echo $i,"\t"; switch($i) { case 1: echo "One"; break; case 2: default: echo "Thingy"; break; case 3: case 4: echo "Three or Four"; break; case 5: echo "Five"; break; } echo "\n"; } ?> Link to comment https://forums.phpfreaks.com/topic/121978-array-undefined-variables/#findComment-629628 Share on other sites More sharing options...
noobified Posted August 30, 2008 Author Share Posted August 30, 2008 ? this makes no sense to me $themeImageValues["themeName"][$x] Link to comment https://forums.phpfreaks.com/topic/121978-array-undefined-variables/#findComment-629629 Share on other sites More sharing options...
phpretard Posted August 30, 2008 Share Posted August 30, 2008 A case with no switch makes no sense to me. Where is your switch? Link to comment https://forums.phpfreaks.com/topic/121978-array-undefined-variables/#findComment-629631 Share on other sites More sharing options...
phpretard Posted August 30, 2008 Share Posted August 30, 2008 Can you post all of your code? Link to comment https://forums.phpfreaks.com/topic/121978-array-undefined-variables/#findComment-629634 Share on other sites More sharing options...
noobified Posted August 30, 2008 Author Share Posted August 30, 2008 the file is fairly big so i have attached it [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/121978-array-undefined-variables/#findComment-629639 Share on other sites More sharing options...
phpretard Posted August 30, 2008 Share Posted August 30, 2008 I am reviewing it... Link to comment https://forums.phpfreaks.com/topic/121978-array-undefined-variables/#findComment-629642 Share on other sites More sharing options...
noobified Posted August 30, 2008 Author Share Posted August 30, 2008 thanks much appreciated Link to comment https://forums.phpfreaks.com/topic/121978-array-undefined-variables/#findComment-629655 Share on other sites More sharing options...
phpretard Posted August 30, 2008 Share Posted August 30, 2008 I would turn notice's off in your php.ini file frankly. Basically it wants you to declare a variable before you try to use it.. so for instance.. instead of dynamically creating $themeImageValues["themeName0"]["blockArrowColor"] it wants you to do something like this: $themeImageValues["themeName0"] = array ("blockArrowColor", "blockBackgroundImage"); and THEN assign values to to them. Since this is just not practical in PHP, I would simply turn notices off, most people do. Link to comment https://forums.phpfreaks.com/topic/121978-array-undefined-variables/#findComment-629678 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.