Connecting Tech Pros Worldwide Forums | Help | Site Map

SWITCH with a $_GET

sigzero@gmail.com
Guest
 
Posts: n/a
#1: Jul 17 '05
I have a url that ends with ?pid=sqlall. I am using the following to
try and get at the "sqlall". I have read many sites to no avail.

switch ($_GET['pid']) {
case 'sqlall':
$page->assign('pagetitle', 'All Users');
$page->assign('tableheader', 'All Users');
$page->assign('sqlfile', 'sql_all.php');
break;
case 'sqlprof':
$page->assign('pagetitle', 'All Users');
$page->assign('tableheader', '» All User Profiles');
$page->assign('sqlfile', 'sql_prof.php');
break;
}

if the url is http://localhost/main.php?pid=sqlall or ?pid=sqlprof then
I want to case to assign. This is in conjuction with Smarty.
Any suggestion would be helpful.

Robert


Alvaro G. Vicario
Guest
 
Posts: n/a
#2: Jul 17 '05

re: SWITCH with a $_GET


*** sigzero@gmail.com escribió/wrote (7 Dec 2004 12:03:21 -0800):[color=blue]
> I have a url that ends with ?pid=sqlall. I am using the following to
> try and get at the "sqlall". I have read many sites to no avail.
>
> switch ($_GET['pid']) {
> case 'sqlall':[/color]

So, what's your problem? Have you done any sort of debugging, such us
printing the variables? Is that the URL of current page or some other you
have in a string?



--
-+ Álvaro G. Vicario - Burgos, Spain
+- http://www.demogracia.com (la web de humor barnizada para la intemperie)
++ Las dudas informáticas recibidas por correo irán directas a la papelera
-+ I'm not a free help desk, please don't e-mail me your questions
--
sigzero@gmail.com
Guest
 
Posts: n/a
#3: Jul 17 '05

re: SWITCH with a $_GET



Alvaro G. Vicario wrote:[color=blue]
> *** sigzero@gmail.com escribió/wrote (7 Dec 2004 12:03:21 -0800):[color=green]
> > I have a url that ends with ?pid=sqlall. I am using the following[/color][/color]
to[color=blue][color=green]
> > try and get at the "sqlall". I have read many sites to no avail.
> >
> > switch ($_GET['pid']) {
> > case 'sqlall':[/color]
>
> So, what's your problem? Have you done any sort of debugging, such us
> printing the variables? Is that the URL of current page or some other[/color]
you[color=blue]
> have in a string?
>
>
>[/color]
I have a "print_r" printing the $_GET. It IS displaying the right
string but my assign statements are not assigning anything. I am
calling the link from a JS using the following format:
"attu.php?pid=sqlall"

I am getting the "sqlall" it does not seem to be processing my assign->
parameters in the switch statement itself.

Robert

sigzero@gmail.com
Guest
 
Posts: n/a
#4: Jul 17 '05

re: SWITCH with a $_GET


It seems to be the Smarty cache causing the problem. Because I am using
one page name "attu.php" the cache doesn't really see the change when I
do different assigns to it. I turned the Smarty cache off and bingo the
switch statement works.

Robert

Gary L. Burnore
Guest
 
Posts: n/a
#5: Jul 17 '05

re: SWITCH with a $_GET


On 8 Dec 2004 10:30:27 -0800, sigzero@gmail.com wrote:
[color=blue]
>It seems to be the Smarty cache causing the problem. Because I am using
>one page name "attu.php" the cache doesn't really see the change when I
>do different assigns to it. I turned the Smarty cache off and bingo the
>switch statement works.
>
>[/color]
It'd still be a bit better to do this:

$pid = $_GET['pid'];

switch ($pid) {
case 'sqlall':

....



--
gburnore@databasix dot com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
DataBasix | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ³ 3 4 1 4 2 ݳ޳ 6 9 0 6 9 ÝÛ³
Black Helicopter Repair Svcs Division | Official Proof of Purchase
================================================== =========================
Want one? GET one! http://signup.databasix.com
================================================== =========================
Daniel Tryba
Guest
 
Posts: n/a
#6: Jul 17 '05

re: SWITCH with a $_GET


Gary L. Burnore <gburnore@databasix.com> wrote:[color=blue]
> It'd still be a bit better to do this:
>
> $pid = $_GET['pid'];
>
> switch ($pid) {
> case 'sqlall':
>
> ...
>[/color]

Huh! Why?

Daniel Tryba
Guest
 
Posts: n/a
#7: Jul 17 '05

re: SWITCH with a $_GET


sigzero@gmail.com wrote:[color=blue]
> It seems to be the Smarty cache causing the problem. Because I am using
> one page name "attu.php" the cache doesn't really see the change when I
> do different assigns to it. I turned the Smarty cache off and bingo the
> switch statement works.[/color]

See the msarty manual how to have multiple caches for 1 page:
http://smarty.php.net/manual/en/cach...ple.caches.php

Gary L. Burnore
Guest
 
Posts: n/a
#8: Jul 17 '05

re: SWITCH with a $_GET


On 09 Dec 2004 19:12:20 GMT, Daniel Tryba <spam@tryba.invalid> wrote:
[color=blue]
>Gary L. Burnore <gburnore@databasix.com> wrote:[color=green]
>> It'd still be a bit better to do this:
>>
>> $pid = $_GET['pid'];
>>
>> switch ($pid) {
>> case 'sqlall':
>>
>> ...
>>[/color]
>
>Huh! Why?[/color]

Moving the $_GET stuff in to their own variables is a good habit to
get into for more than one reason. One is less typing on re-use.
It's easier to type $pid more than once rather than typing
$_GET['pid'] more than once for example.



--
gburnore@databasix dot com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
DataBasix | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ³ 3 4 1 4 2 ݳ޳ 6 9 0 6 9 ÝÛ³
Black Helicopter Repair Svcs Division | Official Proof of Purchase
================================================== =========================
Want one? GET one! http://signup.databasix.com
================================================== =========================
Daniel Tryba
Guest
 
Posts: n/a
#9: Jul 17 '05

re: SWITCH with a $_GET


Gary L. Burnore <gburnore@databasix.com> wrote:[color=blue][color=green][color=darkred]
>>> It'd still be a bit better to do this:
>>>
>>> $pid = $_GET['pid'];
>>>
>>> switch ($pid) {
>>> case 'sqlall':
>>>
>>> ...
>>>[/color]
>>
>>Huh! Why?[/color]
>
> Moving the $_GET stuff in to their own variables is a good habit to
> get into for more than one reason. One is less typing on re-use.
> It's easier to type $pid more than once rather than typing
> $_GET['pid'] more than once for example.[/color]

That must be the worst reason I ever heard! Offcourse varriables should
be to the point and descriptive. But that doens't mean shorter is
always better.

But $_GET['pid'] says something extra, like that it came from an
untrustworthy source. Making a raw copy hides that fact, so when $pid is
later used in output there is a chance that correctly escaping will be
forgotten.

Closed Thread