n8frog Posted September 19, 2010 Share Posted September 19, 2010 What I am trying to accomplish is to display data on a website that is stored in a db on another website. I have a script that stores statistics for webmasters in a mysql db. (sort of like an ad click counter) I want to allow these webmasters to display this data on their own website. Sudo-Example: My script stores hit count of remote site in a mysql db at myscript.com (fake name) My script user wants to display count of hits on his/her page at countedsite.com (fake name) How do I do this? I tried using include 'http://myscript.com/whatever.php'; (whatever.php has a mysql query that fetches the data) in the remote website but nothing is displayed. I would like to provide a line of code similar to above that the webmaster can include in the source of their website to display the count. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/213831-accessing-mysql-db-data-on-remote-website/ Share on other sites More sharing options...
trq Posted September 20, 2010 Share Posted September 20, 2010 In order for your users to be able to include a remote file they would need to have allow_url_include enabled within there php.ini. This is disabled by default. A better option would be for them to call.... <?php echo file_get_contents('http://myscript.com/whatever.php'); ?> as allow_url_fopen is enabled by default or for them to use curl, either way, what your providing should be sufficient. You will however likely require your users to pass an id via the querystring so that your script can identify them and get the correct data. eg; <?php echo file_get_contents('http://myscript.com/whatever.php?id=someuniquecode'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/213831-accessing-mysql-db-data-on-remote-website/#findComment-1113141 Share on other sites More sharing options...
n8frog Posted September 20, 2010 Author Share Posted September 20, 2010 Thank you I was able to get this working using the example you provided. I have to say this website is amazing. Every question I have had thus far has been answered by the users here. I can't wait until I become knowledgeable enough with php to do the same for others. Thanks again you guys are great! Quote Link to comment https://forums.phpfreaks.com/topic/213831-accessing-mysql-db-data-on-remote-website/#findComment-1113300 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.