User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 402,905 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,146 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 2285 | Replies: 13 | Solved
Reply
Join Date: Jan 2007
Posts: 58
Reputation: crazynp is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
crazynp crazynp is offline Offline
Junior Poster in Training

show content from another sites's database

  #1  
Feb 11th, 2007
Hi,

I am building three websites. The first site has a mysql database with necessary contents for two other sites. The two websites should show the content stored in the first site's database, is it possible without using xml? or is xml the best way or is there any other way to do it?

Regards!
Binod
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2006
Location: Sofia, Bulgaria
Posts: 135
Reputation: Rhyan is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 7
Rhyan's Avatar
Rhyan Rhyan is offline Offline
Junior Poster

Re: show content from another sites's database

  #2  
Feb 12th, 2007
Originally Posted by crazynp View Post
Hi,

I am building three websites. The first site has a mysql database with necessary contents for two other sites. The two websites should show the content stored in the first site's database, is it possible without using xml? or is xml the best way or is there any other way to do it?

Regards!
Binod


Are the 3 websites hosted on the same server?

If the 3 websites are not stored on the same server, then the server where the mysql database is should allow connections from the internet, not only localhost requests.

If the sites are hosted on a public webserver, I doubt that the server would allow access from the internet, as it is potentially unsafe.

Still, if you can perform grants, you can configure a read-only access to the database for a user, explicitly allowing access from the IP of the website that needs to acces the database. It seems confusing, so I will explain like this:

1. website 1 holds the database.
2. website 2 needs access to the database of website 1 from ip 1.2.3.4 .

Create a user named e.g. web2 with pass web2 in the database server.
Grant to user web2 SELECT on DATABASE.* from host with ip 1.2.3.4.

open port in firewall at website1 server for access to the database server normally on port 3306 for mysql.

it should work this way.

If you need any info check resources available on mysql.com or check the hosting server help and faq manuals and sections on how to allow access, grant permissions, etc.
Reply With Quote  
Join Date: Jan 2007
Posts: 58
Reputation: crazynp is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
crazynp crazynp is offline Offline
Junior Poster in Training

Re: show content from another sites's database

  #3  
Feb 12th, 2007
Originally Posted by Rhyan View Post
Are the 3 websites hosted on the same server?

If the 3 websites are not stored on the same server, then the server where the mysql database is should allow connections from the internet, not only localhost requests.

If the sites are hosted on a public webserver, I doubt that the server would allow access from the internet, as it is potentially unsafe.

Still, if you can perform grants, you can configure a read-only access to the database for a user, explicitly allowing access from the IP of the website that needs to acces the database. It seems confusing, so I will explain like this:

1. website 1 holds the database.
2. website 2 needs access to the database of website 1 from ip 1.2.3.4 .

Create a user named e.g. web2 with pass web2 in the database server.
Grant to user web2 SELECT on DATABASE.* from host with ip 1.2.3.4.

open port in firewall at website1 server for access to the database server normally on port 3306 for mysql.

it should work this way.

If you need any info check resources available on mysql.com or check the hosting server help and faq manuals and sections on how to allow access, grant permissions, etc.


Thanks Rhyan,

Again a little question

Can I do this if I have got only access to the cpanel of the website or do I need access to the WHM or where Can I configure that and if I can do that with cpanel how to do that?
Last edited by crazynp : Feb 12th, 2007 at 11:18 am.
Reply With Quote  
Join Date: Jul 2005
Location: Chennai India
Posts: 65
Reputation: chrisranjana is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 2
chrisranjana chrisranjana is offline Offline
Junior Poster in Training

Solution Re: show content from another sites's database

  #4  
Feb 12th, 2007
Would the first site's database get updated frequently.
If not you can achieve good performance if you run a cron script to transfer content from the first site's database to your other server periodically.
Chris, Director, Chrisranjana.com
Web developers and software programmers.
Reply With Quote  
Join Date: Oct 2006
Location: Sofia, Bulgaria
Posts: 135
Reputation: Rhyan is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 7
Rhyan's Avatar
Rhyan Rhyan is offline Offline
Junior Poster

Re: show content from another sites's database

  #5  
Feb 12th, 2007
Well, it is not 1 but three questions .

Ok, now, I do not know how many and what opitons do you have on your control panel. But, if you are familiar with MySQL, you maybe will be able to do it on your own, if you answer the following questions:

1. Are you allowed to create database schemas on your server?
2. Are you able to create new tables on your server?
3. Are you allowed to create mysql database users, or you have been given a limit of only 1 user per database?
4. Are you able to grant permissions on your database and tables on your server? Especially check if you can grant permissions to mysql users to access from other locations than localhost!
5. Check if you can connect to your mysql database server from your home computer using the root password you have been supplied by the hosting provider.
E.g. your website name is www.myweb.com
run mysql console and type
 mysql -h www.myweb.com:3306 -u root -p
You will be prompted for a password, and if everything is ok, you will receive a message like," welcome, blabla for help type /h for exit type /q"

If this test passes, then you will be able to access your mysql DB from the remote website.

If not, then we may be able to figure it out another way maybe.

Goodluck
Reply With Quote  
Join Date: Jan 2007
Posts: 58
Reputation: crazynp is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
crazynp crazynp is offline Offline
Junior Poster in Training

Re: show content from another sites's database

  #6  
Feb 13th, 2007
Thanks Rhyan!
I can create users but how to connect the database from another site other than local host? Can you give me a small example like query

Thanks in advance
Reply With Quote  
Join Date: Oct 2006
Location: Sofia, Bulgaria
Posts: 135
Reputation: Rhyan is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 7
Rhyan's Avatar
Rhyan Rhyan is offline Offline
Junior Poster

Re: show content from another sites's database

  #7  
Feb 13th, 2007
As I have told you earlier, all your code should be the same as it is for website 1(where the database is), however, on website 2 instead of localhost in your mysql_connect statement you should insert website 1.

[php]
// from website 2 make the following
$connect = mysql_connect('website1.com:3306', 'website2_user', 'website2_password');

[/php]

The rest is the same...

If you have any difficulties, read the php and mysql dox more thoroughly.
Reply With Quote  
Join Date: Jan 2007
Posts: 58
Reputation: crazynp is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
crazynp crazynp is offline Offline
Junior Poster in Training

Re: show content from another sites's database

  #8  
Feb 13th, 2007
Thanks Rhyan.
Reply With Quote  
Join Date: May 2006
Location: Yorkshire, England
Posts: 5
Reputation: DarrenC is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
DarrenC DarrenC is offline Offline
Newbie Poster

Re: show content from another sites's database

  #9  
Feb 14th, 2007
I don't know if you have thought of this, and whilst it's not directly answering your question you might be interested.

If you have 3 websites on the same IP range, make sure you don't link to the 3 sites, as the search engines could penalise you for this.
Reply With Quote  
Join Date: Jan 2007
Posts: 58
Reputation: crazynp is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
crazynp crazynp is offline Offline
Junior Poster in Training

Re: show content from another sites's database

  #10  
Feb 15th, 2007
Originally Posted by DarrenC View Post
I don't know if you have thought of this, and whilst it's not directly answering your question you might be interested.

If you have 3 websites on the same IP range, make sure you don't link to the 3 sites, as the search engines could penalise you for this.


The IP address are of different range. Is creating RSS feed is better than this?
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the PHP Forum

All times are GMT -4. The time now is 3:29 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC