Saad
Saad

Reputation: 13669

cURL - Bad Request (Invalid Number)

I have set up a small PHP script on my system (running XAMPP) and it is working perfectly fine but when I upload it to my web server it says: Bad Request (Invalid Number). What may be the reason?

Here is my code:

$url = "http://domain.com/filename.aspx?client=saad%40domain.com&oper=d&gname=g1";  

$options = array(  
  CURLOPT_RETURNTRANSFER => true,  
  CURLOPT_HEADER         => false,  
  CURLOPT_FOLLOWLOCATION => true,  
  CURLOPT_ENCODING       => "",  
  CURLOPT_USERAGENT      => "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)",  
  CURLOPT_AUTOREFERER    => true,  
  CURLOPT_CONNECTTIMEOUT => 120,    
  CURLOPT_TIMEOUT        => 120,  
  CURLOPT_MAXREDIRS      => 10,  
  CURLOPT_POST           => true,  
);  

$ch = curl_init($url);  
curl_setopt_array($ch, $options);  
$content = curl_exec($ch);  
$header = curl_getinfo($ch);  
curl_close($ch);  

print_r($header);  
echo $content;  

And the header array shows:

Array
(
    [url] => http://domain.com/filename.aspx?client=saad%40domain.com&oper=d&gname=g1
    [content_type] => text/html
    [http_code] => 400
    [header_size] => 129
    [request_size] => 337
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 0.034575
    [namelookup_time] => 0.029746
    [connect_time] => 0.030606
    [pretransfer_time] => 0.030615
    [size_upload] => 0
    [size_download] => 37
    [speed_download] => 1070
    [speed_upload] => 0
    [download_content_length] => 37
    [upload_content_length] => -1
    [starttransfer_time] => 0.03455
    [redirect_time] => 0
)

Thanks in advance!

Upvotes: 0

Views: 5259

Answers (1)

Saad
Saad

Reputation: 13669

Removing the CURLOPT_POST option resolved the issue. It wasn't however creating any problem on my local PC.

Upvotes: 6

Related Questions