Forums
This topic is locked
url parameters
Posted 07 Jan 2003 10:01:28
1
has voted
07 Jan 2003 10:01:28 Iain Stewart posted:
Hi all,small question i hope.
I want to set a varible according to a url parameter but if the parameter is missing set the varible to a default value, was trying to use if else statements but error comes up if the http_get_vars['value'] can't find a value, is there a way to ignore the url if its missing ?
cheers
Iain
head hurts, 'mental note to self, stop banging head !'
Replies
Replied 13 Jan 2003 12:16:00
13 Jan 2003 12:16:00 Julio Taylor replied:
try setting the default value to "&" wtihout quotes.
------------------------
Julio
PHP | MySQL | UD4
ICQ: 19735247
------------------------
Julio
PHP | MySQL | UD4
ICQ: 19735247
Replied 14 Jan 2003 07:03:27
14 Jan 2003 07:03:27 Nicholas Bennett replied:
<?php
if( $HTTP_GET_VARS["test"] )
{
$MyVar = $HTTP_GET_VARS["test"];
}
else
{
$MyVar = "MyDefaultValue";
}
echo($MyVar);
?>
Note: In 4.1.0 you can use $_GET (a super gloabal which can be used inside of functions) instead of $HTTP_GET_VARS which needs to be set as global.
if( $HTTP_GET_VARS["test"] )
{
$MyVar = $HTTP_GET_VARS["test"];
}
else
{
$MyVar = "MyDefaultValue";
}
echo($MyVar);
?>
Note: In 4.1.0 you can use $_GET (a super gloabal which can be used inside of functions) instead of $HTTP_GET_VARS which needs to be set as global.
Replied 14 Jan 2003 10:37:01
14 Jan 2003 10:37:01 Iain Stewart replied:
thanks, I'll give that a try the day and see if it does what i want, looks like it will, tried a few things, but was starting to get frustrated with it.
cheers
Iain
head hurts, 'mental note to self, stop banging head !'
cheers
Iain
head hurts, 'mental note to self, stop banging head !'