tags:

views:

81

answers:

1

When using PHP file_get_contents(), What characters will cause the following error to appear: "The request line contained invalid characters following the protocol string."

Here's my URL: http://MySite.com/File.php?dummy=235&data1=103.019|103.019|99.973|98.086|100|105.584|94.499|91.76|74.257|65.862|63.528&data2=103.019|103.019|99.973|98.086|100|105.584|94.499|91.76|74.257|65.862|63.528&data3=103.019|103.019|99.973|98.086|100|105.584|94.499|91.76|74.257|65.862|63.528&data4=103.019|103.019|99.973|98.086|100|105.584|94.499|91.76|74.257|65.862|63.528&data5=103.019|103.019|99.973|98.086|100|105.584|94.499|91.76|74.257|65.862|63.528&data6=103.019|103.019|99.973|98.086|100|105.584|94.499|91.76|74.257|65.862|63.528&Label1=Inland Empire (MSA) Actual (03-23-10)&Label2=Inland Empire (MSA) Forecast (03-23-10)&Label3=Inland Empire (MSA) Actual (03-23-10)&Label4=Inland Empire (MSA) Forecast (03-23-10)&Label5=&Label6=&Title=Apartment Prices&Label=Q4-2006&IndexDate=Q4-2007&YaxisLabel=&Subtitle=&Smooth=&LineBar=&EndDate=0&HalfWidth=GetYAxis=Yes

It doesn't work even if I URL encode

A: 

This will depend on what protocol you're using. Based on the error and common usage, I'll assume you're attempting to fetch a remote file using a URL as the parameter. RFC-1738 has the details on how URLs are supposed to be encoded, but the short answer is pretty much all non-alphanumeric characters except-_. Note that some other symbols such as % aren't invalid per se and won't cause an error, but unless they are encoded they may not transmit properly.

You'll want to use urlencode() on whatever URL you're attempting to fetch.

zombat
yep, the string has a lot of - in it. but url encoding does nothing. Any advice?
Brian