Why did I get a 400 Bad Request when getting a page with PHP Curl?
Posted
by user307272
on Stack Overflow
See other posts from Stack Overflow
or by user307272
Published on 2010-04-01T21:12:59Z
Indexed on
2010/04/01
21:23 UTC
Read the original article
Hit count: 182
php
Hi, I was trying to access a page using curl. I could access it perfectly using the browser and using "static" strings as the URL, like:
$url = "http://www.example.com/?q=1234"
But when I tried to access the page using a variable in the URL string like:
$url = "http://www.example.com/?q=$param"
I got a 400 error code. I checked out on the web and found some comments here in this stackoverflow thread:
Then, just for curiosity I did the following:
$url = "http://www.example.com/?q=" . trim($param);
and it worked! And no, $param
did NOT contain any spaces.
To me, it seems that it can be some encoding error, but I really can't find an explanation for it. Does anyone here in stackoverflow know what it can possibly be?
Thanks in advance :)
© Stack Overflow or respective owner