Jump to content

Recommended Posts

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?

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'); ?>

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! :D

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.