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

Problems with the Windows version of XAMPP, questions, comments, and anything related.

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

Postby mehrzadsoft » 15. May 2006 13:17

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?
mehrzadsoft
 
Posts: 5
Joined: 15. May 2006 12:25
Location: Tehran, Iran

Postby capitalfellow » 15. May 2006 19:41

is the id and content available when you access request the URL by external IP address than localhost?
User avatar
capitalfellow
 
Posts: 60
Joined: 19. July 2005 01:10
Location: Charlotte, NC USA
Operating System: OS X

Postby Daen » 15. May 2006 20:30

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.
Daen
 
Posts: 5
Joined: 15. May 2006 17:48

Postby capitalfellow » 16. May 2006 03:40

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.
User avatar
capitalfellow
 
Posts: 60
Joined: 19. July 2005 01:10
Location: Charlotte, NC USA
Operating System: OS X

Postby mehrzadsoft » 17. May 2006 20:01

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:
mehrzadsoft
 
Posts: 5
Joined: 15. May 2006 12:25
Location: Tehran, Iran

Postby mehrzadsoft » 17. May 2006 20:04

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
mehrzadsoft
 
Posts: 5
Joined: 15. May 2006 12:25
Location: Tehran, Iran


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 81 guests