• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 253
  • Last Modified:

Get file names from HTTP header

I'm sure someone has done this.

What I need to do is be able to connect to 2 different MySql databases on the same site.  The php/html is going to be the same.  My partner want's to change the data in his side of the site.

It's set up to load different databases on different servers and this does work.

Is there a way that I can get the info from the header on the web browser and then determine what data base that I should open?
  • 2
  • 2
1 Solution
Ray PaseurCommented:
If you mean "Can PHP detect which URL was used to access a common PHP script set?" The answer is yes.  Look in $_SERVER['HTTP_HOST']
Somehow I think in other way,  when you do http access on browser
and you have already known what url you want to type or go on browser.
There is a lot of $_SERVER variables you might need, please read this

Please tell us more detail of your question, so we could help you on exectly what you need.

breeze351Author Commented:
I've read it the manual.  I can get the end of the url.  What it need to do is the the front of it.




If I can get the line from the url, I can parse between the "http\\" and the first period  and get "amy" and then open the correct database.
Thanks for your reply and explain. glad to see you have solved your question.
 When or after I  click submit button for my first reply post, this post has already
closed and solved.  sorry I was late to answer your question. Hope help  you
in next time.

have a nice day

breeze351Author Commented:
I haven't resolved this yet.

There is one web site with a sub under it:



I need to change the database name to "amelia".
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now