Hi guys,

I have this piece of code:

<?
    chdir("../catalog/");
    $HTTP_GET_VARS['products_id']=1;
    include ("product_info.php");
    ?>

To load up some product info on a php file.

This works ok, but I now want to load this same information, but on a different server and would therefor like to point at "http://www.mysite.com/catalog/" rather than "../catalog/" but I believe chdir is not suitable for this.

Could anyone help me out?

Thank you so much!

    Well, assuming that it's going to send data back and not just set a variable, you could use [man]file_get_contents/man (assuming that url fopen wrappers are enabled).

    The first thing I would do is see if you go to http://www.example.com/catalog/product_info.php?products_id=1 does it show anything? If it's an empty page, then you need to rework the code to output something when it's called remotely. If it does output something useful, then you know using the direct URL will work. Now you just need to get that data to your other site.

    [man]file_get_contents/manwill bring the entire contents of the file (or url) you specify as a string to a variable. If you don't have url fopen wrappers enabled, then you won't be able to use file_get_contents() or fopen 🙁 What you'd then have to do is use [man]fsockopen/man to open a socket to the site, then use [man]fread/man to read the data coming back from the site. Totally overkill I know, but there's really nothing you can do. Alternatively you could use [man]cURL[/man] to send a remote request. Now cURL is a little overkill for this, but it will get the job done if it's installed on your server and enabled.

      Write a Reply...