Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8743815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:44:41+00:00 2026-06-13T11:44:41+00:00

It says the browser sent a request the server could not understand .. I

  • 0

It says the browser sent a request the server could not understand .. I don’t exactly understand what went wrong in my PHP code. Can someone please help me understand where I went wrong. Thanks !

<?php
    $url ="http://127.0.0.1/sensor/sens/data.php";
    $xml_data = file_get_contents("/usr/local/www/data/data.xml");
    $header ="POST HTTP/1.0 \r\n";
    $header .="Content-type: text/xml \r\n";
    $header .="Content-length: ".strlen($xml_data)." \r\n";
    $header .="Content-transfer-encoding: text\r\n";
    $header .="Connection: close \r\n\r\n";
    $header .= $xml_data;
    $ch = curl_init();
    curl_setopt ($ch,CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch,CURLOPT_POST,true);
    curl_setopt($ch,CURLOPT_POSTFIELDS,$header);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 4);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);
    $data = curl_exec($ch);  // if the post is successful , the server will return some data.
    echo $data;

    #$info = curl_getinfo($ch);
    #
    #if(!curl_errno($ch))
    #   echo 'It took '.$info['total_time'].'seconds to send a request to'.$info['url'];
    #
    #   else
    #

    curl_close($ch);
    echo $data;







    ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:44:42+00:00Added an answer on June 13, 2026 at 11:44 am

    I think the problem is with CURLOPT_POSTFIELDS

    From the PHP Manual…

    The full data to post in a HTTP “POST” operation. To post a file, prepend a filename with @ and use the full path. The filetype can be explicitly specified by following the filename with the type in the format ‘;type=mimetype’. This parameter can either be passed as a urlencoded string like ‘para1=val1&para2=val2&…’ or as an array with the field name as key and field data as value. If value is an array, the Content-Type header will be set to multipart/form-data. As of PHP 5.2.0, value must be an array if files are passed to this option with the @ prefix.

    http://php.net/manual/en/function.curl-setopt.php

    It should hold just the payload and not the entire header.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question says it all. I tried browsing through the latest tag but could not
I've got a pretty simple request and can't figure out why it's wrong: if
if I open my SVN http://localhost/repos/XXX The browser says : Forbidden You don't have
The question says it all. I am looking for a build.xml file browser where
MDN says : Any SVG elements within a foreignObject will not be drawn, except
The firebug points at the end of the code to '?>' and says XML
I am trying to use following queries but the browser says Fatal error: Call
After reading about CORS (Cross-Origin Resource Sharing), I don't understand how it improves security.
Not sure where to post this, but I can't find any information anywhere and
Is there a way that I can check if the browser will allow cookies.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.