0
New Here
,
/t5/dreamweaver-discussions/passing-data-in-url-what-happens-if-no-data-is-passed/td-p/983406
Aug 22, 2006
Aug 22, 2006
Copy link to clipboard
Copied
I am working in php with MySQL.
Some of the pages in my site require some data to be passed in the url. In most cases it is 'data_region'. If this isn't passed in the url I get an 'undefined index' error. Is there a way to say:
if 'data_region' exists use the information that it passes,
else use '?data_region=ALL'
At the moment I am just using a web forwarder on the index page to forward to the main.php with the correct data_region instead of having main.php as the index. This is OK but it sometimes takes a while, especially on slower connections.
Any help appreciated.
My code:
Some of the pages in my site require some data to be passed in the url. In most cases it is 'data_region'. If this isn't passed in the url I get an 'undefined index' error. Is there a way to say:
if 'data_region' exists use the information that it passes,
else use '?data_region=ALL'
At the moment I am just using a web forwarder on the index page to forward to the main.php with the correct data_region instead of having main.php as the index. This is OK but it sometimes takes a while, especially on slower connections.
Any help appreciated.
My code:

TOPICS
Server side applications
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
1 Correct answer
LEGEND
,
Aug 22, 2006
Aug 22, 2006
deadlyhifi wrote:
> I can see what you're trying to do here but it isn't working because it is
> still looking for '?data_region' in the URL. I need it to apply
> 'data_region=ALL' when 'data_region' is not mentioned in the URL.
In that case, put this at the top of your page:
if (!isset($_GET['data_region']) $_GET['data_region'] = 'ALL';
--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
> I can see what you're trying to do here but it isn't working because it is
> still looking for '?data_region' in the URL. I need it to apply
> 'data_region=ALL' when 'data_region' is not mentioned in the URL.
In that case, put this at the top of your page:
if (!isset($_GET['data_region']) $_GET['data_region'] = 'ALL';
--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
LEGEND
,
/t5/dreamweaver-discussions/passing-data-in-url-what-happens-if-no-data-is-passed/m-p/983407#M187824
Aug 22, 2006
Aug 22, 2006
Copy link to clipboard
Copied
deadlyhifi wrote:
> Is there a way to say:
>
> if 'data_region' exists use the information that it passes,
> else use '?data_region=ALL'
Yes, there is. Dreamweaver should take care of this for you, but the
recordset code ignores the default value.
Change the following section from this:
> $region = "ALL";
> if (isset($_GET['data_region'])) {
> $colname_rs_video = (get_magic_quotes_gpc()) ? $_GET['data_region'] :
> addslashes($_GET['data_region']);
> }
To this:
$region = "ALL";
if (isset($_GET['data_region'])) {
$colname_rs_video = (get_magic_quotes_gpc()) ? $_GET['data_region']
: addslashes($_GET['data_region']);
}
else {
$colname_rs_video = "ALL";
}
--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
> Is there a way to say:
>
> if 'data_region' exists use the information that it passes,
> else use '?data_region=ALL'
Yes, there is. Dreamweaver should take care of this for you, but the
recordset code ignores the default value.
Change the following section from this:
> $region = "ALL";
> if (isset($_GET['data_region'])) {
> $colname_rs_video = (get_magic_quotes_gpc()) ? $_GET['data_region'] :
> addslashes($_GET['data_region']);
> }
To this:
$region = "ALL";
if (isset($_GET['data_region'])) {
$colname_rs_video = (get_magic_quotes_gpc()) ? $_GET['data_region']
: addslashes($_GET['data_region']);
}
else {
$colname_rs_video = "ALL";
}
--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
deadlyhifi
AUTHOR
New Here
,
/t5/dreamweaver-discussions/passing-data-in-url-what-happens-if-no-data-is-passed/m-p/983408#M187825
Aug 22, 2006
Aug 22, 2006
Copy link to clipboard
Copied
Thanks for your reply.
I can see what you're trying to do here but it isn't working because it is still looking for '?data_region' in the URL. I need it to apply 'data_region=ALL' when 'data_region' is not mentioned in the URL.
I can see what you're trying to do here but it isn't working because it is still looking for '?data_region' in the URL. I need it to apply 'data_region=ALL' when 'data_region' is not mentioned in the URL.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/passing-data-in-url-what-happens-if-no-data-is-passed/m-p/983409#M187826
Aug 22, 2006
Aug 22, 2006
Copy link to clipboard
Copied
deadlyhifi wrote:
> I can see what you're trying to do here but it isn't working because it is
> still looking for '?data_region' in the URL. I need it to apply
> 'data_region=ALL' when 'data_region' is not mentioned in the URL.
In that case, put this at the top of your page:
if (!isset($_GET['data_region']) $_GET['data_region'] = 'ALL';
--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
> I can see what you're trying to do here but it isn't working because it is
> still looking for '?data_region' in the URL. I need it to apply
> 'data_region=ALL' when 'data_region' is not mentioned in the URL.
In that case, put this at the top of your page:
if (!isset($_GET['data_region']) $_GET['data_region'] = 'ALL';
--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
deadlyhifi
AUTHOR
New Here
,
/t5/dreamweaver-discussions/passing-data-in-url-what-happens-if-no-data-is-passed/m-p/983410#M187828
Aug 22, 2006
Aug 22, 2006
Copy link to clipboard
Copied
you Monsieur Powers deserve an award.
don't forget the extra ')' though...
if (!isset($_GET['data_region'])) $_GET['data_region'] = 'all';
don't forget the extra ')' though...
if (!isset($_GET['data_region'])) $_GET['data_region'] = 'all';
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
LATEST
/t5/dreamweaver-discussions/passing-data-in-url-what-happens-if-no-data-is-passed/m-p/983411#M187829
Aug 22, 2006
Aug 22, 2006
Copy link to clipboard
Copied
deadlyhifi wrote:
> you Monsieur Powers deserve an award.
Merci.
> don't forget the extra ')' though...
Just testing. ;)
--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
> you Monsieur Powers deserve an award.
Merci.
> don't forget the extra ')' though...
Just testing. ;)
--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

