eagleweb Posted July 2, 2007 Share Posted July 2, 2007 I am building a site where a client can put in rental property information. They name their listing also. They can view it from the same site by going to a page "/listings.php?name=mylistingname". It stores it in a mysql db. However, if they want to keep the listing, they have to register a domain name. I now need to be able to show their listing info on their domain name using the template that I made. What are my options? How do I allow a domain to read another domains db? Do I have to move my template over to each domain and use the query SELECT from listings WHERE id = 1 (etc for each listing)? Is there a better way? (redirect) Here is what i use for a db connection: <?php # FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" $hostname_mysql_connect = "localhost"; $database_mysql_connect = "dbname"; $username_mysql_connect = "dbusername"; $password_mysql_connect = "dbpassword"; $mysql_connect = mysql_connect($hostname_mysql_connect, $username_mysql_connect, $password_mysql_connect) or trigger_error(mysql_error(),E_USER_ERROR); ?> Thank you in advance. Chuck Quote Link to comment https://forums.phpfreaks.com/topic/58148-reading-from-db-on-different-domain/ Share on other sites More sharing options...
trq Posted July 3, 2007 Share Posted July 3, 2007 You would be much better off having your clients include a page from your server into theres. You'd pass an id so that the page then retrieves there data. eg; include 'http://www.yourserver.com/template.php?clientid=42'; Otherwise, your going to need to grant connection access to all your clients domains, not to mention the fact that a username / password will need to be gievn to them. Quote Link to comment https://forums.phpfreaks.com/topic/58148-reading-from-db-on-different-domain/#findComment-288428 Share on other sites More sharing options...
eagleweb Posted July 3, 2007 Author Share Posted July 3, 2007 Thorpe, I tried the include files but it does not bring along the css page so the page loads wrong. I am also using phpthumbs for imaging so the thumbs don't come over either. When I built the template, I used include files (header.html, footer.html, etc so they are not pulling over either. Plus, I built multiple pages instead of one page for each listing (listings.php?id=42, photos.php?id=42, etc) It might be to my advantage to make one page and use a switch statement for the other pages. Will that help with this situation? As for the permissions; we will actually be the ones registering the domain names and setting up the pages, so the client will never get the user and pass for the db anyway. If this is easier at this point, then i will do this. I still need to know how to grant the connection access if I use this way. Thanks again, Chuck Quote Link to comment https://forums.phpfreaks.com/topic/58148-reading-from-db-on-different-domain/#findComment-288436 Share on other sites More sharing options...
eagleweb Posted July 3, 2007 Author Share Posted July 3, 2007 Does any one have any ideas on this? I would like some pros out there to give me their opinions. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/58148-reading-from-db-on-different-domain/#findComment-288734 Share on other sites More sharing options...
trq Posted July 3, 2007 Share Posted July 3, 2007 I just did. Quote Link to comment https://forums.phpfreaks.com/topic/58148-reading-from-db-on-different-domain/#findComment-288742 Share on other sites More sharing options...
eagleweb Posted July 3, 2007 Author Share Posted July 3, 2007 Ok. Thanks Thorpe. I am having to redo some links, etc on the pages, but it definitely works. Mucho thanks! Quote Link to comment https://forums.phpfreaks.com/topic/58148-reading-from-db-on-different-domain/#findComment-289108 Share on other sites More sharing options...
eagleweb Posted July 4, 2007 Author Share Posted July 4, 2007 I could definitely use a little more help. I have been at it for hours and have gotten somewhere, but I can't seem to conquer it. Definitely not for lack of trying. I have made a folder called listings and made in index.php page with a switch statement like this in the middle of it: <?PHP switch ($_GET['page']) { default: case "home": require_once ("home.htm"); break; case "details": require_once ("details.htm"); break; case "areainfo": require_once ("areainfo.htm"); break; }// end switch ?> Next, I went to the new domain name where I want this info to show at and made an index.php page there with this code only: <?php include 'http://www.myclientssite.com/listings/?pagename=www.falkirkstreet.com'; ?> When you go to www.falkirkstreet.com it pulls the home page info beautifully! But, I can't get the other pages to show their info. The link for the areainfo page is this: <?php if(!empty($row['url']) && $row['website'] == 'Y') { $site = $row['url']; $page = "?page="; } ?> <a class="links" href="http://<?php echo "".$site."".$page."areainfo"; ?>">AREA INFO</a> so the link when on the www.falkirkstreet.com page is www.falkirkstreet.com/?page=areainfo. Do you have suggestions? I could definitely use some more help now. thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/58148-reading-from-db-on-different-domain/#findComment-289343 Share on other sites More sharing options...
teng84 Posted July 4, 2007 Share Posted July 4, 2007 When you go to www.falkirkstreet.com it pulls the home page info beautifully! But, I can't get the other pages to show their info. The link for the areainfo page is this: ^^^ you cant run those page simultaneous if that what you mean but tru manipulation maybe yu could read the pages you cant as array then format it as you desire Quote Link to comment https://forums.phpfreaks.com/topic/58148-reading-from-db-on-different-domain/#findComment-289348 Share on other sites More sharing options...
eagleweb Posted July 4, 2007 Author Share Posted July 4, 2007 I do not know what you are telling me. Is there no way for me to accomplish this task? I just want to pull the info from another domain's dbase. It has to be possible. I see it done with real estate sites constantly. Quote Link to comment https://forums.phpfreaks.com/topic/58148-reading-from-db-on-different-domain/#findComment-289353 Share on other sites More sharing options...
eagleweb Posted July 4, 2007 Author Share Posted July 4, 2007 This will be my last attempt for help on this problem. Has anyone ever had to pull info from a database on a different domain or show pages from a different domain? I see it done on real estate sites so it is very possible. Thorpe came up with a great idea that I want to use, but I am having trouble getting the pages to pull over. Please read the above comments by myself and Thorpe and let me know if you have some helpful hints. The comments even show you which page I am working on with a link to it and you can see that the links on that page do not work. Thank You Quote Link to comment https://forums.phpfreaks.com/topic/58148-reading-from-db-on-different-domain/#findComment-289665 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.