Page 1 of 1

show.php?id=1 , id and its content is not reachable

PostPosted: 15. May 2006 13:17
by mehrzadsoft
hi
i am beginner in Xampp
i have a web sitem i developed it by php, mysql
when i want to use it locally, id and its content is not reachable

http://localhost/site/show.php?id=1

i cant use id's value for accessing DB.

i installed Xampp just few days a go.

what do i do?

PostPosted: 15. May 2006 19:41
by capitalfellow
is the id and content available when you access request the URL by external IP address than localhost?

PostPosted: 15. May 2006 20:30
by Daen
I noticed this myself when I started working on XAMPP. It seems to make the PHP code a little more picky than I'm used to.

Anyway, I used to normally just send id in the URL like you do, then just assume $id was set to whatever the URL said, and it worked. With XAMPP I had to change it a bit, since it looks like it doesn't allow the vars to be automatically set. Since vars sent in the URL are sent as the GET method, you have to access them in the $_GET superglobal.

so try this at the beginning of your file:

$id = $_GET['id'];

Hope that helps.

PostPosted: 16. May 2006 03:40
by capitalfellow
The behaviour you are used to experiencing is when register_globals is turned On in php.ini. However this a bad programming practice to get accustomed to doing and it can lead to lots of security holes or just bug ridled code.

Since PHP 4.2 the default has been to turn this setting Off forcing the developer to use the super global arrays _GET and _POST to fetch form variable values.

PostPosted: 17. May 2006 20:01
by mehrzadsoft
Daen wrote:I noticed this myself when I started working on XAMPP. It seems to make the PHP code a little more picky than I'm used to.

Anyway, I used to normally just send id in the URL like you do, then just assume $id was set to whatever the URL said, and it worked. With XAMPP I had to change it a bit, since it looks like it doesn't allow the vars to be automatically set. Since vars sent in the URL are sent as the GET method, you have to access them in the $_GET superglobal.

so try this at the beginning of your file:

$id = $_GET['id'];

Hope that helps.


thanks a billion
your hint solved my problem
:wink:

PostPosted: 17. May 2006 20:04
by mehrzadsoft
capitalfellow wrote:The behaviour you are used to experiencing is when register_globals is turned On in php.ini. However this a bad programming practice to get accustomed to doing and it can lead to lots of security holes or just bug ridled code.

Since PHP 4.2 the default has been to turn this setting Off forcing the developer to use the super global arrays _GET and _POST to fetch form variable values.


you'r right
i'm bigginer and i must check my mistakes

thanks