Hey everyone hope one of you guys can help me out since its been a while.

I am looking for a solution to a news ticker that I use on my site...

Take the following in mind my site uses 1000 plus pages and the ticker is on every page and the pages are in folders.

I used to use <?PHP include("http://site.dotcom/ticker.php");?>

This no longer works anymore, I am looking for a simple way to solve this issue once again and not a big code considering its a tiny code already.

Thanks in advance,

P.S If I sound stupid it been a while since I've coded I may be out of date for 2 years.

    Are you looking to use the PHP code in that file? Or do you just want to use just the rendered page?

    If you want the PHP code, make sure that both files are on the same server... there may be some other restrictions....

    If you just want the rendered page, either they need to be on different servers, or you will need to print out the needed content on your page that's doing the include.

    Do you see the expected ticker is you just browse to http://site.dotcom/ticker.php??

      Yes I see it if I go to http://site.dotcom/ticker.php.

      However what I would like is to use that file as a means of updates like instead of updates 1000 files I would just update one. My whole site is on one server but my host doesnt allow http includes anymore just

      <? include (ticker.php); ?> However this isnt suitable for me considered i have many files / folders.

        Is the snippet of code you seek hosted on your site's server?
        If so, I would make a habit of including using something like this:

        <?php include($_SERVER['DOCUMENT_ROOT'].'/whateverfolder/codesnippet.php'); ?>
        

        By including $_SERVER['DOCUMENT_ROOT'] as the root, PHP automatically fills your site's root in it's place.. then after the dot, ensure you have the remainder of the directory structure and file name correct.

        Hope that helps.

        Cheers,

        NRG

        *Edit.. I saw you posted again just as I was replying..

        Check in your php.ini for these lines:

        allow_url_fopen = On
        allow_url_include = Off <-- this is my default setting.. perhaps you need to turn this on as well as ensure allow_url_fopen = On too..

        You can find this quickly by opening the .ini file, and hitting control + f.. then type in 'fopen' in the search field.
        Ensure that both allow_url_fopen and allow_url_include is not commented out and be sure it is = On. This might be the issue you are having?

          Doesnt seem to work I used this

          <?php include($_SERVER['DOCUMENT_ROOT'].'/updates.php'); ?> and it doesnt work... I still get the error you can see this via ffgenesis.com I am testing it on an old site .

            did you check your php.ini file on the server?

            Incase you missed my edit in my last post (I kept adding to it):

            Check in your php.ini for these lines:

            allow_url_fopen = On
            allow_url_include = Off <-- this is my default setting.. perhaps you need to turn this on as well as ensure allow_url_fopen = On too..

            You can find this quickly by opening the .ini file, and hitting control + f.. then type in 'fopen' in the search field.
            Ensure that both allow_url_fopen and allow_url_include is not commented out and be sure it is = On. This might be the issue you are having?

            Cheers,

            NRG

              Another option...

              <?
              $ticker = file_get_contents("http://site.dotcom/ticker.php");
              echo ($ticker);
              ?>
                Chrismichaelz wrote:

                Doesnt seem to work I used this

                <?php include($_SERVER['DOCUMENT_ROOT'].'/updates.php'); ?> and it doesnt work... I still get the error you can see this via ffgenesis.com I am testing it on an old site .

                If this file is on your site's server (in otherwords, if this file is accessible inside your site's folder directory) then the above code is a good way to go.. if the file is found on some other website (not in a folder in your site's driectory), then go back to using the absolute path you were using before.. but be sure to check your php.ini file and make sure that the variables in my last post are set to On.

                Cheers,

                NRG

                  php's include() function will render a URI in the default installation.

                  This means that you can have a script that is:

                  <?php include("http://www.site.com/page.php");?>

                  This may be turned off by some hosts, as it can be construed as a security issue (although, if you run it like I showed you, it shouldn't be). However, it is on by default in most php installations.

                  This requires the following two lines in your php.ini file:

                  allow_url_fopen = On
                  allow_url_include = On

                    Well at the moment I contacted my host and this is what they said:

                    Hello Christopher,

                    The remote inclusion has been set to off on this Cluster by our Admin.

                    This has the following benefits:
                    - local includes of the file are much faster than remote ones
                    - lover load due to lesser requests.
                    - lesser hits for the customer as every remote include on his own account is counted as additional hit for each page call and include.
                    - and the most important benefit is: MORE SECURITY. 97% of all security issues in PHP scripts are related to this remote inclusion of PHP code that is then executed in the customer account (c99shells, spam sending, maybe many phishing sites are put in accounts this way too).

                    Remote fopens are not affected by this and should work without issues.

                    If you have any concerns on this please let us know.

                    Kind Regards
                    Scott, Support
                    Servage Hosting

                    So how would you use an fopen thats not too complicated... just to include one file.

                      While I have never used fopen, I think a good start would be found here in the php manual: fopen().

                      There are examples further down the page.

                      Hope that helps out somewhat.

                      Cheers,

                      NRG

                        The server I am on at work doesnt allow me to use the script ilz gave me it gives me this kind of message...

                        Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in d:\websites\crcinfoca\html\english\index.php on line 104

                        Warning: file_get_contents(http://www.crcinfo.ca/html/english/footer.php) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in d:\websites\crcinfoca\html\english\index.php on line 104

                        So I am not quite sure where to go from here arent there other possibilities/.?

                          Chrismichaelz wrote:

                          Anyone got any solutions or have used fopens before?

                          Did you try fopen() by using an example in the php manual? If so, what was the error message?
                          example:

                          $ticker = fopen("http://site.dotcom/ticker.php/", "r");
                          echo $ticker;
                          

                          Cheers,

                          NRG

                            Chrismichaelz wrote:

                            Anyone got any solutions or have used fopens before?

                            Did you try fopen() by using an example in the php manual? If so, what was the error message?

                            Cheers,

                            NRG

                              I would assume that allow_url_open is also disabled.

                              Since this is a shared hosting machine, there isn't much you can do about it. Well, I'll give a suggestion later, but for now....

                              1. Do you actually have php scripts on physically separate servers that depend on your updates.php script?

                              2. Do you actually need to parse the php code in the updates.php script?

                              Finally...

                              Whats that all about?

                              fopen opens a file pointer resource, it does not give you the file contents. You have to use functions such as fread() to read the file and return the contents.

                                Well Yes I actually do need this because my site has many folders(directories) and theres over 800 pages I don't want to update them seperatley aswell I don't want them out of folders cause its organized. There must be a away to fix this issue without paying for a dedicated server cause it doesnt need one it doesnt exceed bandwidth ever.

                                Edit...

                                Everything is on the same server I just need to be able to include this file in many pages that are in many folders.

                                  Chrismichaelz wrote:

                                  Everything is on the same server I just need to be able to include this file in many pages that are in many folders.

                                  Bingo! You DO NOT need to use a url to get the updates.php include file! If you have one updates.php file, simply make a test.php (or whatever) file in that virtual root (same website as the updates.php folder) and do this...

                                  <?php
                                  echo $_SERVER['DOCUMENT_ROOT'];
                                  ?>
                                  

                                  That will give you the server path to your file.

                                  Next (this is only required if your websites reside in different virtual roots and have different owners), you'll need to make your updates.php file world readable (I have no idea if you have shell access, I will guess you have cpanel or something.) link

                                  Now, in all your include statements, you'll need to change to something like...

                                  <?php
                                  include("/path_from_test.php/updates.php");
                                  // or if all files are part of same website (same virtual root)
                                  include($_SERVER['DOCUMENT_ROOT'] . "/updates.php");
                                  ?>