How to call PHP script from a page??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • donnie
    Confirmed User
    • Jan 2003
    • 1630

    #1

    How to call PHP script from a page??

    I have this gallery rotator script but I don't know how to call it from my page.
    What should I write on my page to get link to a random gallery??
    Here is the script:

    random.php
    -----------------------------------------------
    <?
    $delim = "\n";
    $cryfile = "galleries.txt";
    $fp = fopen($cryfile, "r");
    $contents = fread($fp, filesize($cryfile));
    $cry_arr = explode($delim,$contents);
    fclose($fp);
    srand((double)microtime()*1000000);
    $cry_index = (rand(1, sizeof($cry_arr)) - 1);
    $herecry = $cry_arr[$cry_index];
    echo $herecry;
    ?>
    -----------------------------------------------

    galleries.txt
    -----------------------------------------------
    <a href="gallery1.url">Gallery 1 Description</a>
    <a href="gallery2.url">Gallery 2 Description</a>
    <a href="gallery3.url">Gallery 3 Description</a>
    etc...
    -----------------------------------------------
  • Sly
    Let's do some business!
    • Sep 2004
    • 31376

    #2
    <? include ("file.php"); ?>

    Unless something has drastically changed over the past 3 years.
    Vacares - Web Hosting, Domains, O365, Security & More - Paxum and BTC Accepted

    Windows VPS now available
    Great for TSS, Nifty Stats, remote work, virtual assistants, etc.
    Click here for more details.

    Comment

    • Jace
      FBOP Class Of 2013
      • Jan 2004
      • 35562

      #3
      and make sure the page you are calling it from is named something.php

      you can't call php from an html page

      i made that mistake the first time, took me 2 hours to figure out what I was doing wrong

      Comment

      • Tipsy
        Confirmed User
        • Jul 2001
        • 6989

        #4
        Originally posted by JaceXXX
        you can't call php from an html page
        You can with a very small change to apache or sometimes htaccess. It can be very useful sometimes.
        Ignorance is never bliss.

        Comment

        • Jace
          FBOP Class Of 2013
          • Jan 2004
          • 35562

          #5
          Originally posted by Tipsy
          You can with a very small change to apache or sometimes htaccess. It can be very useful sometimes.
          yeah, but for us normal folks it is just easier to rename the file to php

          Comment

          • Azlord
            Confirmed User
            • Dec 2003
            • 2651

            #6
            yah but the hun won't take php galleries.

            Comment

            • Tipsy
              Confirmed User
              • Jul 2001
              • 6989

              #7
              Originally posted by JaceXXX
              yeah, but for us normal folks it is just easier to rename the file to php
              Depends on the usage. Sometimes naming the file php can cause problems and it's not a hard thing to do even for 'normal' folks. It'd only be difficult on some virtual accounts where the htaccess is restrictive.
              Ignorance is never bliss.

              Comment

              • Dalai lama
                Strength and Honor
                • Jul 2004
                • 16540

                #8
                Originally posted by Sly
                <? include ("file.php"); ?>

                Unless something has drastically changed over the past 3 years.

                nothing has changed, good call

                A program you can trust.
                Gallerybooster Run multiply TGPs of 1 script

                Comment

                • MikeXAMO
                  Confirmed User
                  • Mar 2002
                  • 660

                  #9
                  I always recommend making a simple change to apache to run PHP in .html files. You simply add the line "AddType application/x-httpd-php .html" in your httpd.conf file. If you wanna get real crazy, you can make your php files appear as HTML files (i.e. Don't output the PHP header on PHP processed pages) by setting "expose_php = Off" in your php.ini file. Good thing to do for gallery makers!
                  Xamo Entertainment
                  Xamo.com | EZSets.com

                  ICQ: 9439118 MSN: mikeb [at] xamo.com Tollfree: 800-544-XAMO
                  XXX CMS - Designed by Adult Webmasters, for Adult Webmasters.

                  Comment

                  • Antonio
                    Too lazy to set a custom title
                    • Oct 2001
                    • 14136

                    #10
                    I use
                    <!--#include virtual="MyFile.php"-->
                    on a .shtml page

                    Comment

                    Working...