jakebur01 Posted April 24, 2007 Share Posted April 24, 2007 Is there a limit on how many else if statement you can use? I am getting a PHP Parse error: parse error, unexpected T_CLASS about the fifth one down. if($productform == 'Shinform') $productselect = Shin; elseif($productform == 'Littleform') $productselect = Little; elseif($productform == 'Manform') $productselect = Man; elseif($productform == 'Smithform') $productselect = Smith; elseif ($productform == 'Classform') $productselect = Class; elseif($productform == 'OregonOform') $productselect = OregonO; elseif($productform == 'OregonFform') $productselect = OregonF; elseif($productform == 'Troyform') $productselect = Troy; elseif($productform == 'Whiteform') $productselect = White; elseif($productform == 'Trenchform') $productselect = Trench; else echo $URL="http://www.mysite.com/nodealerselect.html"; header ("Location: $URL"); Quote Link to comment https://forums.phpfreaks.com/topic/48515-solved-else-if/ Share on other sites More sharing options...
shaunrigby Posted April 24, 2007 Share Posted April 24, 2007 Easier and neater option would be to use Swith/case: [code] switch($productform){ case "Shinform": $productselect = "Shin"; break; case "Littleform": $productselect = "Little"; break; default: echo $URL="http://www.mysite.com/nodealerselect.html"; header ("Location: $URL"); break; } etc etc If others find the need to correct me please do so, have not used switch case in a while...[/code] Quote Link to comment https://forums.phpfreaks.com/topic/48515-solved-else-if/#findComment-237341 Share on other sites More sharing options...
veridicus Posted April 24, 2007 Share Posted April 24, 2007 There's no limit that I know of, but "Class" is a reserved word. If those are all meant to be strings you should wrap them in quotes. PHP just assumes they're strings if not already defined as function, class, or variable names. Quote Link to comment https://forums.phpfreaks.com/topic/48515-solved-else-if/#findComment-237343 Share on other sites More sharing options...
jakebur01 Posted April 24, 2007 Author Share Posted April 24, 2007 Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/48515-solved-else-if/#findComment-237350 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.