Error when remotely placing simple php code

3 replies
This is a simple script I use to rotate phone numbers on a website. Obviously borrowed and changed a little because I know nothing about php.

In http://mysite.com/adverts.php is this code hosting the numbers :

<?
$bannerCounter= 1;

$bannerCode[$bannerCounter] = " 111-369-3494 ";
$bannerCounter++;

$bannerCode[$bannerCounter] = " 222-423-5720 ";
$bannerCounter++;

$bannerCode[$bannerCounter] = " 333-369-3494 ";
$bannerCounter++;

$bannerCode[$bannerCounter] = " 444-423-5720 ";
$bannerCounter++;

$bannerCode[$bannerCounter] = " 555-369-3494 ";
$bannerCounter++;

$bannerCode[$bannerCounter] = " 666-423-5720 ";
$bannerCounter++;




$bannerAdTotals = $bannerCounter - 1;
if($bannerAdTotals>1)
{
mt_srand((double)microtime() * 1234567);
$bannerPicked = mt_rand(1, $bannerAdTotals);
}
else
{
$bannerPicked = 1;
}
$bannerAd2 = $bannerCode[$bannerPicked];
?>

Then in http://mysite.com/index.php this code is placed to rotate the numbers :

<?
include_once("test1.php");
echo " $bannerAd2 ";
?>

Could use many enhancements, but it works.

Now when I put the second code on a different website (So I do not have to make the adverts.php section for each) http://website2.com/index.php link this :


<?
include_once("http://mywebsite.com/test1.php");
echo " $bannerAd2 ";
?>

I get this error :

Warning: include_once() [function.include-once]: URL file-access is disabled in the server configuration in /home/stopfore/www/www/test.php on line 24

I have numerous other applications, and reasons I want to just place the last piece on other websites with out having to make the initial adverts.php page for each site. What simple thing am I missing?

Thanks,

Scot
#code #error #php #placing #remotely #simple
  • Profile picture of the author Spencer Westwood
    You can't include_once from a different website.

    What you could do is have the numbers in a file on a website and have the
    script open the link (look up fopen or fsocketopen), read the file, parse it and then select the random variation from there..

    Kind regards, Spencer
    {{ DiscussionBoard.errors[286098].message }}
  • Profile picture of the author scotl47
    Thank you, and seems simple enough.
    {{ DiscussionBoard.errors[286289].message }}
  • Profile picture of the author floatingatoll
    Originally Posted by scotl47 View Post

    Now when I put the second code on a different website (So I do not have to make the adverts.php section for each) .. link this :

    <?
    include_once(URL_TO."test1.php");
    echo " ";
    ?>

    I get this error :

    Warning: include_once() [function.include-once]: URL file-access is disabled in the server configuration in /home/stopfore/www/www/test.php on line 24
    If you enable "allow_uri_fopen" in php.ini, then PHP should allow you to pass URLs to the include() functions. However, as suggested above, try to avoid this and instead keep the phone numbers in a local file on the server. It's slightly more secure and will also be faster than creating and completing an HTTP request to a webserver.
    {{ DiscussionBoard.errors[287661].message }}

Trending Topics