MrAdam Posted September 18, 2006 Share Posted September 18, 2006 hey everyone. iv got a problem with my switch statement... switch ($f) {case "add": addItem(); break;case "remove": removeItem(); break;case "clear": clearItems(); break;} .. i've never tried doing something like that before... but it doesn't seem to work (but gives no errors) .. can anybody see a problem?-Thanks Link to comment Share on other sites More sharing options...
aspnetguy Posted September 18, 2006 Share Posted September 18, 2006 I don't see anything wrong with it but try this. I added a default case to see echo a string when $f doesn't match any of the other cases (which sounds like what is happening) switch ($f) {case "add": addItem(); break;case "remove": removeItem(); break;case "clear": clearItems(); break;default : echo "value fell through"; break;} Link to comment Share on other sites More sharing options...
MrAdam Posted September 18, 2006 Author Share Posted September 18, 2006 giving out "value fell through" :S Link to comment Share on other sites More sharing options...
aspnetguy Posted September 18, 2006 Share Posted September 18, 2006 so try trimming the whitespace from $f and converting it to lower case just to be sure. It is usually some little thing like that. Link to comment Share on other sites More sharing options...
MrAdam Posted September 18, 2006 Author Share Posted September 18, 2006 al give it a shot.nope, it's nothing to do with whitespace, wrong case or owt.check this link out..http://www.brothers-united.newbiestyle.co....tions.php?f=addcan see there.. Link to comment Share on other sites More sharing options...
aspnetguy Posted September 18, 2006 Share Posted September 18, 2006 how are you setting $f? $f = $_GET['f']; //????? Link to comment Share on other sites More sharing options...
MrAdam Posted September 18, 2006 Author Share Posted September 18, 2006 yeah .. Link to comment Share on other sites More sharing options...
aspnetguy Posted September 18, 2006 Share Posted September 18, 2006 just for kicks try this switch ($_GET['f']) {case "add": addItem(); break;case "remove": removeItem(); break;case "clear": clearItems(); break;default : echo "value fell through"; break;} it might be an issue with the variable and the querystring being the same name?!? Link to comment Share on other sites More sharing options...
MrAdam Posted September 18, 2006 Author Share Posted September 18, 2006 sorted! worked when i changed the variable to "function". i don't know why though lol. but am happy. thankya mate! Link to comment Share on other sites More sharing options...
aspnetguy Posted September 18, 2006 Share Posted September 18, 2006 sorted! worked when i changed the variable to "function". i don't know why though lol. but am happy. thankya mate!I guess PHP doesn't like setting variables that have the same name as the querystring. Link to comment Share on other sites More sharing options...
aquatsr Posted September 18, 2006 Share Posted September 18, 2006 I guess PHP doesn't like setting variables that have the same name as the querystring.Hmmm no... it's not that. I don't think the problem has been solved completely . Link to comment Share on other sites More sharing options...
MoZo1 Posted September 19, 2006 Share Posted September 19, 2006 You should copy your entire code here, cause the switch is good, and with the $_GET array, it should run on every PHP versions.Oh, and you can try it with else if, I doubt it will work. Link to comment Share on other sites More sharing options...
aspnetguy Posted September 19, 2006 Share Posted September 19, 2006 It was obviously a problem with $f and the way it was being defined. changing f= to function= in the quesrtstring seemed to solve the problem...why would this be? Link to comment Share on other sites More sharing options...
justsomeguy Posted September 19, 2006 Share Posted September 19, 2006 Hard to say without the code. It might be that $f got overwritten somewhere. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now