Ryan
Ryan

Reputation: 14649

Limit on Character Length $_GET?

I have a variable which consists of

  // The First Page (hello.php)

 $a = 'goto.php?a_56=63525588000&url=http://www.example.com/site/DISC+cUSTOMc+Studio+24+-               +Windows/1142766.p?
       id=1218224802931&usi=1142766&cmp=RMX&
       ky=2crslw0k9ZOM0ciu2rqi4NsYY7eQnnEyP';

 // The Second Page (goto.php)
 $r = $_GET['url'];

 echo $r; 

//http://www.example.com/site/Disc cCustomc Studio 8 - Windows/1142766.p?id=1218224802931

Why is it getting cut off?

Upvotes: 3

Views: 1071

Answers (4)

Quentin
Quentin

Reputation: 943460

Because & indicates the end of a key/value pair in a query string.

Use urlencode to prepare data for inclusion in a query string.

Upvotes: 3

Rich Adams
Rich Adams

Reputation: 26574

This isn't a length issue, it's because you want one of your GET parameters (url in this case) to contain the & character. You need to urlencode this character otherwise it will be interpreted as another GET parameter in the request, rather than as part of the url parameter.

When urlencoding, & will become %26 and your query string will become this,

goto.php?a_56=63525588000&url=http://www.example.com/site/DISC+cUSTOMc+Studio+24+-+Windows/1142766.p?id=1218224802931%26usi=1142766%26cmp=RMX%26ky=2crslw0k9ZOM0ciu2rqi4NsYY7eQnnEyP

Upvotes: 3

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798606

The ampersand is used to separate parameters in the outside query string. You will need to URL-encode it if you want to use it within a GET parameter.

Upvotes: 3

JohnP
JohnP

Reputation: 50019

It's getting cut off because it's treating the & in your url parameter as an actual GET parameter divider, when it's not.

You need to use urlencode() to encode your URL.

Upvotes: 3

Related Questions