Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 03-17-2010, 06:49 AM mysite.$domain
Super Talker

Posts: 128
Name: Jose daSilva
Trades: 0
Hi
I have several domains, only one website and one databse table for each domain.
example: wbesite.us - data goes to database table main_usa
wbesite.co.uk - data goes to database table main_uk

Only have one database with name of the website.

Having only one website structured, and having variables like
$sql="select * from main_".$countrycode." where bla..bla..., and many other variables to catch the domain extension, and so on...
Now, instead of having one full website for each domain, how can set a script and wher do I put it in order to detect the domain that the user uses.
In my server root do I create something like website.$domain ?
I hope I made myself clear.
Thank you.

Last edited by josil; 03-17-2010 at 06:51 AM..
josil is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-17-2010, 09:29 AM Re: mysite.$domain
R1im's Avatar
Average Talker

Posts: 24
Name: Rain Ungert
Location: Estonia
Trades: 0
Im sry, but i dont get it. You have several domains but one website? How is that possible ?

If you want to get current host name, try this:

Code:
echo $_SERVER['HTTP_HOST'];
it'll return like "www.webmaster-talk.com"

you can echo it whereever you want
__________________
Working on
Please login or register to view this content. Registration is FREE
. SEO tools i use:
Please login or register to view this content. Registration is FREE
R1im is offline
Reply With Quote
View Public Profile Visit R1im's homepage!
 
Old 03-17-2010, 07:33 PM Re: mysite.$domain
Super Talker

Posts: 128
Name: Jose daSilva
Trades: 0
Quote:
Originally Posted by R1im View Post
Im sry, but i dont get it. You have several domains but one website? How is that possible ?

If you want to get current host name, try this:

Code:
echo $_SERVER['HTTP_HOST'];
it'll return like "www.webmaster-talk.com"

you can echo it whereever you want

Ok.

Let me explain.

the project is to make one website that will be open either with domain website.usa or website.uk.

the website,usa will be managed ONLY by used from USA and the website.co.uk will be used by users of Uk.

Do you konw olx.co.uk, or any other extension?

Is similar like that website but for different pporposes.

if you open www.olx.usa it shows data related only to USA, despite the fact the user can add info from other ocuntries bu will be under city or region of USA. and the same for w.olx.co.uk.

Instead of making an independent website for each domain must be a way to do only one that calls the data from two different database tables like main_USA and main_UK under the same database name.

Can you understand now?

Thanks a lot
josil is offline
Reply With Quote
View Public Profile
 
Old 03-17-2010, 07:59 PM Re: mysite.$domain
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Originally Posted by R1im View Post
Im sry, but i dont get it. You have several domains but one website? How is that possible ?
Very very simply, it's called parking or aliasing.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-17-2010, 08:02 PM Re: mysite.$domain
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
@josil

So what exactly is your question??
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-17-2010, 08:18 PM Re: mysite.$domain
Super Talker

Posts: 128
Name: Jose daSilva
Trades: 0
Quote:
Originally Posted by chrishirst View Post
@josil

So what exactly is your question??
Ok

Let me try to explain better.

Do you know www.olx.com, or www.olx.org.uk/ or www.olx.ca, and so on?

Well each domain opens a website that shows data from the country that the domain is related to.

i do not belive that they have one website for each domain.

They problably have one database table for each country under the name probably OLX. In another words theu may have something like main_USA to store data for USA and main_UK for data of Uk, and so on.

I want to do a similar project for defferent purposes, the same way, avoiding having one website for each domain.

I could do alias to one spcific website, like website.net of all websites country domains, but it does not work due the fact It shows the same data in all.

I can do:

PHP Code:
if ($_SERVER['SERVER_NAME'] == "site1.domain.ext") {
// Set variables for site1 here
}
else if ($_SERVER['SERVER_NAME'] == "site2.domain.ext") {
// Set variables for site2 here
}
else {
// Set variables for site3 or whatever
}

But where do I put this script? in the rrot directory does not work.

In the index.php of the website.net?

thanks for the help
josil is offline
Reply With Quote
View Public Profile
 
Old 03-17-2010, 08:27 PM Re: mysite.$domain
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
But where do I put this script?
That depends on how your code sets up the database and the tables to query.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-17-2010, 09:06 PM Re: mysite.$domain
Super Talker

Posts: 128
Name: Jose daSilva
Trades: 0
Quote:
Originally Posted by chrishirst View Post
That depends on how your code sets up the database and the tables to query.
Ok

Let me try again.

I have two equal copies of one website.

1 is website.us, another is website.co.uk
boyh independent websites saves data into on only database that has two tables: main_USA and main_UK
The websites are working fine independently.

Bu if I have domais for most of worls countries. Now, the way I'm doing it I end up with about 90 websites.

My question is instead of all websites how can I use only one.

Every website has an include file called connect.php

?
$connect=mysql_connect ("localhost", "root", "root") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("databasename", $connect) or die ("Impossible to connect to Data Base");

$sql = "SELECT id, country, countryisocode, countryphonecode, cityphone, agent, name, phone, mobile, fax, email FROM `inter_agents` WHERE country='usa' limit 1";
$result=mysql_db_query("databasename",$sql);
$regist=mysql_fetch_array($result);
$id1=$regist["id"];
$country=$regist["country"];
$code1=$registo['countryisocode'];
$code2=$registo[countryphonecode];
$code3=$registo[cityphonecode];
$agent=$registo['agent'];
$name=$registo['name'];
$phone=$registo['phone'];
$mobile=$registo['mobile'];
$fax=$registo['fax'];
$email=$registo['email'];

?>

to call the country in the table of database:

$sql="select * from inter_agents where country=".countryisocode."' and activ='1'";
josil is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to mysite.$domain
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.58365 seconds with 12 queries