pixelhousedesign Posted January 1, 2011 Share Posted January 1, 2011 Happy new year everyone! Can someone help me please. I have a skadate script installed on a domain and want to set up sub-domains based on the users country of registration - ireland.mydomain.com, france.mydomain.com etc I know that I can install the skadate script within subdomains and refer to the same primary database BUT what I want to do is only show say users registered in Ireland on the ireland.mydomain.com site. Can this be done via the database connection string?? // MySQL Connection define('DB_HOST', 'localhost'); define('DB_USER', 'user_skadate'); define('DB_PASS', 'abc123'); define('DB_NAME', 'user_skadate'); define('DB_TBL_PREFIX', 'skadate_'); This is the config.php database string. Any advice or suggestions would be very gratefully recieved. Quote Link to comment https://forums.phpfreaks.com/topic/223136-single-database-running-two-or-more-sites-country-specific/ Share on other sites More sharing options...
ignace Posted January 1, 2011 Share Posted January 1, 2011 You should define a catch-all DNS entry: *.<your-domain> IN A <ip> Then in your PHP script: $country = array_shift(explode('.', $_SERVER['HTTP_HOST'])); // ireland, france, .. Be sure to filter $country and validate before using it in a database. Quote Link to comment https://forums.phpfreaks.com/topic/223136-single-database-running-two-or-more-sites-country-specific/#findComment-1153560 Share on other sites More sharing options...
pixelhousedesign Posted January 1, 2011 Author Share Posted January 1, 2011 Thanks for your reply, I think I may not have explained fullly, because as I believe $country is a standard php function and what I needed was to use members based on a field they'll have completed (country_id) Quote Link to comment https://forums.phpfreaks.com/topic/223136-single-database-running-two-or-more-sites-country-specific/#findComment-1153566 Share on other sites More sharing options...
ignace Posted January 1, 2011 Share Posted January 1, 2011 $country is not a function, it's a variable. PHP has no function named country. Quote Link to comment https://forums.phpfreaks.com/topic/223136-single-database-running-two-or-more-sites-country-specific/#findComment-1153602 Share on other sites More sharing options...
pixelhousedesign Posted January 1, 2011 Author Share Posted January 1, 2011 Thanks for your clarification and my apologies for my misunderstanding. I am competely lost though as to what I should do. Thanks though. Quote Link to comment https://forums.phpfreaks.com/topic/223136-single-database-running-two-or-more-sites-country-specific/#findComment-1153638 Share on other sites More sharing options...
ignace Posted January 2, 2011 Share Posted January 2, 2011 Do you have a control panel of your server with DNS access? If so, open it and add a new entry: *.your-domain.com IN A your-ip-address This will "forward" everything to your-domain.com and allows you to handle it like this: $country = array_shift(explode('.', $_SERVER['HTTP_HOST'])); // eg ireland, france, or www Add the necessary code to handle www, ireland and france. If this feels over your head, hire a freelancer/programmer to do it for you. Quote Link to comment https://forums.phpfreaks.com/topic/223136-single-database-running-two-or-more-sites-country-specific/#findComment-1153803 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.