Jump to content

Array + Undefined Variables


noobified

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.