Page 1 of 1

Switch() problems

Posted: Sun Jun 10, 2007 7:37 pm
by pinehead18

Code: Select all

switch ($action) {
 
	case $main:
		main();
	break;
	case $main_post:
		main_post();
	break;
}
ok, when action=main_post it displays main(); instead of main post.
If i take out case $main, it displays right.

So in other words this thing is broken and for the life of me i can't figure out why.

If you help me i will love you... Virtually.

Thanks guys

Posted: Sun Jun 10, 2007 8:11 pm
by Benjamin
I think you meant..

Code: Select all

 switch ($action) {
 
        case 'main':
                main();
        break;
        case 'main_post':
                main_post();
        break;
} 

Posted: Sun Jun 10, 2007 8:17 pm
by pinehead18
Thanks for your response. However, when i changed it then nothing worked at all.

Suggestions?

Thanks
Anthony

Posted: Sun Jun 10, 2007 8:19 pm
by bdlang
Does $action actually have a value? What is it at this point in the script?

The code example astions provided is correct, so your variable is either an empty or not a string (or not one that matches those two values).

Posted: Sun Jun 10, 2007 8:23 pm
by Benjamin
register_globals is probably turned off.

Posted: Sun Jun 10, 2007 8:45 pm
by Z3RO21
astions wrote:register_globals is probably turned off.
As they should never be turned on, and yes make sure that data is in the $action variable.

Posted: Sun Jun 10, 2007 9:13 pm
by Luke
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.

Posted: Sun Jun 10, 2007 10:14 pm
by pinehead18
what would register_globals have anything to do with this?

Posted: Sun Jun 10, 2007 10:18 pm
by feyd
Do you set $action? If not, everything.

Posted: Sun Jun 10, 2007 11:21 pm
by bdlang
pinehead18 wrote:what would register_globals have anything to do with this?
Did you ever check to see if $action has a value?

Posted: Mon Jun 11, 2007 6:45 am
by pinehead18
Ha, you ninja's rock. I just started a real job for the first time and my brain has been dead ever since.

$_GET got me going thanks guys!