PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 28th, 2006, 02:56 PM
nevillemehta nevillemehta is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: India
Posts: 64 nevillemehta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 44 m 17 sec
Reputation Power: 16
'&' in the query string...

Hi,

Please have a look at this link.

javascript: openpopup('ban.php?href=/xyz?ta=m&pref=iop&abc=777&t=http://www.domain.com/mop%3Fhl%3Den&url=http://www.domain.com',280,35)

Notice the &'s in the query string. I am trying to pass two items href and url. I tried encoding the url (urlencode() in PHP) in the main page and then decoding it back (urldecode() in PHP) in ban.php but it didnt seem to work. Basically i would like to access the entire query string correctly (namely value in href) correctly in ban.php.

Right now i get href=/xyz?ta=m and url=http://www.domain.com. The remaining part of href is truncated i think mostly cause of the &'s. When i use urlencode and urldecode i get the same results.

Anyway out?

Thanks
Neville

Reply With Quote
  #2  
Old May 29th, 2006, 10:34 AM
Mittineague's Avatar
Mittineague Mittineague is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jul 2005
Location: West Springfield, Massachusetts
Posts: 552 Mittineague User rank is Private First Class (20 - 50 Reputation Level)Mittineague User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 1 m 33 sec
Reputation Power: 13
Ampersands

Please post the openpopup function.

Reply With Quote
  #3  
Old May 29th, 2006, 12:55 PM
nevillemehta nevillemehta is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: India
Posts: 64 nevillemehta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 44 m 17 sec
Reputation Power: 16
Openpopup...

Hey,

Here is the openpopup function.

Code:
<script language="JavaScript">
function openpopup(desktopURL,width,height)
{
	var desktop = window.open(desktopURL,"_blank","toolbar=no,location=no,status=no,menubar=no,width=  "+width+",height="+height+",scrollbars=no,resizable=no");
}
</script>

Reply With Quote
  #4  
Old May 30th, 2006, 09:11 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 18
I would assume your ban.php is receiving the following parameters:
href=/xyz?ta=m
pref=iop
abc=777
t=http://www.domain.com/mop%3Fhl%3Den&url=http://www.domain.com

I think you're expecting it to receive only one parameter:
href=/xyz?ta=m&pref=iop&abc=777&t=http://www.domain.com/mop%3Fhl%3Den&url=http://www.domain.com

What is it you are url_encode'ing?
What does that code look like?
__________________
Daryl's Homepage | My Blogroll | My Profile | Firefox supporter!
DevArticles Forum Moderator

"The net is a waste of time, and that's exactly what's right about it." -- William Gibson

Reply With Quote
  #5  
Old May 30th, 2006, 02:26 PM
nevillemehta nevillemehta is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: India
Posts: 64 nevillemehta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 44 m 17 sec
Reputation Power: 16
...

Hello,

This is the line of code in the main file that calls ban.php. I have already posted the code for openpopup on top.

PHP Code:
echo " | <a href=javascript:openpopup('ban.php?href=" urlencode($row[href]) . "&url=" $url "',280,35)><font size=1>Ban</font></a>"


$row[href] is the url (i.e. /xyz?ta=m&pref=iop&abc=777&t=http://www.domain.com/mop%3Fhl%3Den&url=http://www.domain.com)

However, the problem persists. 'MadCowDzz''s previous post somewhat describes precisely the problem i am facing. I am expecting to get two parameter's href and url.

Expected:
href=/xyz?ta=m&pref=iop&abc=777&t=http://www.domain.com/mop%3Fhl%3Den
url=http://www.domain.com

Getting:
url=http://www.domain.com (correct)
href=/xyz?ta=m (incorrect)

Reply With Quote
  #6  
Old May 31st, 2006, 11:02 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 18
Sorry, I would test it myself, but I don't access to PHP at the moment...

What does this return:
urlencode("/xyz?ta=m&pref=iop&abc=777&t=http://www.domain.com/mop%3Fhl%3Den&url=http://www.domain.com")

How does it display on the page (in the javascript), and how does your ban.php interpret the href variable?

Reply With Quote
  #7  
Old May 31st, 2006, 03:45 PM
nevillemehta nevillemehta is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: India
Posts: 64 nevillemehta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 44 m 17 sec
Reputation Power: 16
...

Hi,

Have a look at his code.

Code:
<?
echo urlencode("/xyz?ta=m&pref=iop&abc=777&t=http://www.domain.com/mop%3Fhl%3Den");
?>

<a href=javascript:openpopup('ban.php?href=<?=urlencode("/xyz?ta=m&pref=iop&abc=777&t=http://www.domain.com/mop%3Fhl%3Den")?>&url=http://www.domain.com/',280,35)><font size=1>Ban</font></a>


The echo statement returns this:
%2Fxyz%3Fta%3Dm%26pref%3Diop%26abc%3D777%26t%3Dhtt p%3A%2F%2Fwww.domain.com%2Fmop%253Fhl%253Den
This is correct output.

However when i use urlencode in the javascript statement i get this output:
<a href=javascript: openpopup('ban.php?href=/xyz?ta=m&pref=iop&abc=777&t=http://www.domain.com/mop%3Fhl%3Den&url=http://www.domain.com/',280,35)><font size=1>Ban</font></a>
Those &'s are not replaced with '%26' in this case. This causes problems.

My ban.php interprets the href variable as:
/xyz?ta=m

Reply With Quote
  #8  
Old June 1st, 2006, 08:49 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 18
so urlencode outputs two different things when given the same input??

If you were to hardcode this line into your code:
Code:
<a href=javascript: openpopup('ban.php?href=%2Fxyz%3Fta%3Dm%26pref%3Di  op%26abc%3D777%26t%3Dhtt p%3A%2F%2Fwww.domain.com%2Fmop%253Fhl%253Den',280,  35)><font size=1>Ban</font></a>
does your ban.php read the href variable fine?

I'm stumped... perhaps someone else could jump in and help... ;-)

Reply With Quote
  #9  
Old June 1st, 2006, 12:12 PM
Madpawn Madpawn is offline
My beat is correct.
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 339 Madpawn User rank is Private First Class (20 - 50 Reputation Level)Madpawn User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 22 h 3 m 33 sec
Reputation Power: 14
Where are you seeing that output? I ran your code, and the source of the generated page was properly encoded for both instances.
__________________
"A pawn is the most important piece on the chessboard -- to a pawn"


Reply With Quote
  #10  
Old June 1st, 2006, 03:55 PM
nevillemehta nevillemehta is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: India
Posts: 64 nevillemehta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 44 m 17 sec
Reputation Power: 16
Hey,

When i hardcoded that line into my code (one MadCowDzz mentioned in his last post) i saw some really wierd results. Firstly ban.php is not reciveing correct results even when i hardcoded value of href. I am yet getting href=/xyz?ta=m in ban.php which is incorrect.

I noticed something else. When i view source i get the correct value of the link (encoded like it should be) however when i hover the link and see the link in the status bar i get the link with the &'s (not the encoded value i see when i view source) and i guess thats the link which my ban.php is picking up. I am using Mozilla Firefox. Anyway even on using IE ban.php yet recives the incorrect results...

Reply With Quote
  #11  
Old June 2nd, 2006, 03:44 PM
nevillemehta nevillemehta is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: India
Posts: 64 nevillemehta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 44 m 17 sec
Reputation Power: 16
Little image that shows what i am trying to explain in my last post...

http://www.brandcatalyst.co.in/nevi...ages/status.jpg

Red box shows link when i view link in the status bar. Orange box shows link when i view source.

Reply With Quote
  #12  
Old June 2nd, 2006, 06:55 PM
Madpawn Madpawn is offline
My beat is correct.
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 339 Madpawn User rank is Private First Class (20 - 50 Reputation Level)Madpawn User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 22 h 3 m 33 sec
Reputation Power: 14
Not really sure what to say. It looks like your string's getting decoded before you want it to, but it's happening client-side. Your PHP's working fine.

Reply With Quote
  #13  
Old June 5th, 2006, 02:20 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 18
If you copied the line from my post above, I just noticed that the forums decided to put a space in my code... not sure if you caught that, and I doubt it will help, but I thought I'd point it out.

Looking at your screen shot, it looks like the URL in the status bar and the text that is being encoded in the HTML source look proper. Is your ban.php script getting the HREF parameter?

Reply With Quote
  #14  
Old June 5th, 2006, 04:49 PM
nevillemehta nevillemehta is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: India
Posts: 64 nevillemehta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 44 m 17 sec
Reputation Power: 16
Hi,

Yes i noticed the space and you correct, that wouldnt solve the problem. The ban.php is getting the href parameter as '/xyz?ta=m' (which is not what i want).

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > '&' in the query string...


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap