Value changes after $_GET

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Bitweiser
Forum Newbie
Posts: 11
Joined: Sun Jul 30, 2006 9:27 am

Value changes after $_GET

Post by Bitweiser »

Hello,

I want to open a new window using javascript.

Code: Select all

Popup=window.open("view_result.php?ref="+reference+"&member="+membernumber, "view")
Where member is for example 0654.

Now when the pages opens I'm reading the value with a $_GET[member] statement:

Code: Select all

echo "<B>Member</B>: $_GET[member] )<P>";
Problem: The value has changed from 0654 to 428.

I think it's a decimal/octal problem right? And is there a simple way to work around it?

Thank
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

lose the zero.
Bitweiser
Forum Newbie
Posts: 11
Joined: Sun Jul 30, 2006 9:27 am

Post by Bitweiser »

feyd wrote:lose the zero.
It's a membernumber so I need to show it in 4 digits.

Ofcourse I can lose the zero and when I've intercepted the values, test to see how many digits I've received and than add the leading zeros again, but then I still don't know why PHP converts my values and if there is a possibility to work around this.

So...anyone?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Somewhere you're using the variable as number where it should be a string (to preserve the zero)
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

At what point is the nuber changed? Is it in the original display of the id in the link, or after the user clicks the link and submits to the server? Is PHP changing the number or is the script? Do you have processing code you show?
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Like feyd says, lose the Zero.

Your member numbers are stored as int's, right? None of them will have leading 0's in your DB.
Telius
Forum Newbie
Posts: 3
Joined: Wed Aug 02, 2006 9:27 am

Post by Telius »

You could always typecast it as a string.
Post Reply