Page not reading variables in URL
Moderator: General Moderators
Page not reading variables in URL
I have someone setting up PHP on a server, but the pages do not seem to pick up the variable in the URL ... for example:
domain.com/page.php?variable=$test
Say I am pulling the $test information from the database, but the page doesn't read it.
Any ideas on what I can tell him to change to make it work in the set up? I am kinda at a loss on this.
Thanks,
Tim
domain.com/page.php?variable=$test
Say I am pulling the $test information from the database, but the page doesn't read it.
Any ideas on what I can tell him to change to make it work in the set up? I am kinda at a loss on this.
Thanks,
Tim
Code: Select all
<?php
echo $_GET['variable'];
?>Code: Select all
<?php
echo $HTTP_GET_VARS['variable'];
?>-
Cruzado_Mainfrm
- Forum Contributor
- Posts: 346
- Joined: Sun Jun 15, 2003 11:22 pm
- Location: Miami, FL
thanks for the input guys ... always something to learn ya know.
And for "following the rules" .. the rules in my PHP handbook I bought a couple of years ago does not talk about that way of doing it. However, I constantly find myself implimenting a better, more secure way of doing things. It's an ongoing process as we progress.
Tim (dude)
And for "following the rules" .. the rules in my PHP handbook I bought a couple of years ago does not talk about that way of doing it. However, I constantly find myself implimenting a better, more secure way of doing things. It's an ongoing process as we progress.
Tim (dude)
Just to follow up on a couple of things ...
When I use the $_GET['thing'] .. is that only for variables coming from the url? Would I use that for variables pulled from the database? (I don't think so, but want to be reassured)
When I use it doing a query on the database, there "WHERE this_item='$_GET['thing']'" throws an error, but this works: "WHERE this_item='$_GET[thing]'" (notice no ' ' inside the []) .. Is that cool?
I do use $_POST[] on forms ... I guess I should have picked this up at the same time ...
that's all for now ...
thanks,
Tim
When I use the $_GET['thing'] .. is that only for variables coming from the url? Would I use that for variables pulled from the database? (I don't think so, but want to be reassured)
When I use it doing a query on the database, there "WHERE this_item='$_GET['thing']'" throws an error, but this works: "WHERE this_item='$_GET[thing]'" (notice no ' ' inside the []) .. Is that cool?
I do use $_POST[] on forms ... I guess I should have picked this up at the same time ...
that's all for now ...
thanks,
Tim
-
Paddy
- Forum Contributor
- Posts: 244
- Joined: Wed Jun 11, 2003 8:16 pm
- Location: Hobart, Tas, Aussie
- Contact:
Not sure why your second attempt worked. Some guru might be able to answer that, but I think this is what you want.
And yes, to get data from a form you use POST.
Code: Select all
<?php
$thing = $_GET['thing'];
$result = mysql_query("select * from atable where this_item='".$thing."'") or exit();
?>use this ONLY if $thing is a number
Code: Select all
<?php
$thing = (int)$_GET['thing'];
$result = mysql_query("select * from atable where this_item='$thing'") or exit();
?>-
Cruzado_Mainfrm
- Forum Contributor
- Posts: 346
- Joined: Sun Jun 15, 2003 11:22 pm
- Location: Miami, FL