problem with switch action...

From: Date: Tue, 16 May 2000 00:09:12 +0000
Subject: problem with switch action...
Groups: php.general 
Request: Send a blank email to php-general+get-81@lists.php.net to get a copy of this message
I'm taking my first stab at creating a PHP page. I'm trying to put together a php page where you can have index.php3?action=something so I will be able to concentrate my scripts into one file. I have tried using the switch function a shown below, and the if elseif else statement, also show below. Whenever I run it on the server, it will throw line errors, and won't switch the action variables value. note: i've tried the cases with the switch function with and without quotes. Can anyone help me? if (empty ($action)) $action=home; switch ($action) { case "home": search (); break; case "admin": passprompt (); break; case "newrecord": passprompt (newrecord); newrecord (); break; case "deleterecord": passprompt (deleterecord); search (); break; case "submitrecord": search (); break; case "search": search (); break; default: die ("Unknown action code ($action)"); } if ($action=home) { print ("this is home\n"); } elseif ($action=pagetwo) { print ("this page 2\n"); } else { print ("unknown action code\n"); } Thanks Colin Gray chaunessy creative web solutions cgray@chaunessy.com www.chaunessy.com

« previous php.general (#81) next »