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

  • Home
  • SEARCH
  • 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 574159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:48:05+00:00 2026-05-13T13:48:05+00:00

I am trying to use file_get_contents() to get the html from a page. the

  • 0

I am trying to use file_get_contents() to get the html from a page.
the following works great: file_get_contents('http://www.mypage.com?Title=Title') but the following causes an error:

$Title = 'Title';
file_get_contents("http://www.mypage.com?Title=$Title")

The error is:

Bad Request

Your browser sent a request that this server could not understand.
The request line contained invalid characters following the protocol string.

Apache/1.3.41 Server at eiit.org Port 80

Does anyone know why?

  • 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-05-13T13:48:05+00:00Added an answer on May 13, 2026 at 1:48 pm

    You are using a string with single-quotes ; and there is no variable interpolation with single-quotes.

    Which means the URL you’re trying to fetch is http://www.mypage.com?Title=$Title, and not http://www.mypage.com?Title=Title.

    You should use a double-quoted string, to have variable interpolation :

    $Title = 'Title';
    file_get_contents("http://www.mypage.com?Title=$Title");
    

    If this still doesn’t work :

    • Check if your URL is OK : instead of directly passing it to file_get_contents, store it in a variable, and echo it — just to be sure it’s right.
    • Why is there no page-name in your URL ?
      • You have the domain-name : www.mypage.com
      • And a parameter+value : Title=Title
      • But no file/page ? i.e., why don’t you have something like http://www.mypage.com/index.php?Title=$Title ? Or even http://www.mypage.com/?Title=$Title ?
    • You might have to urlencode the values you’re passing as parameters in the URL.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use Net::HTTP.get_print in a rails app to get the response from
Im trying to retrieve data from http://www.facebook.com/ajax/shares/view/?target_fbid=410558838979218&__a=1 I get mix of js and html
I am trying to use my own function to get the file size from
I'm trying to use jQuery and the HTML5 File API to get data from
Possible Duplicate: Uploadify: show error message from HTTP response I am trying to get
I'm trying to read the html from this page to later parse it. The
I am trying to use jquery ajax to get data from a php file.
I am trying to use file_get_contents.I have made sure that allow_url_fopen is enabled in
So, I'm trying to use the Python Wave module to get an audio file
I'm trying to insert reCaptcha code into my page from jQuery, but it doesn't

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.