Some php help please....

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jon Clark - BANNED FOR LIFE
    North Coast Pimp
    • Dec 2005
    • 9395

    #1

    Some php help please....

    I know that if I want to include a file on a page I put the line...

    Code:
    <? @include("http://www.domain.com/file.html"); ?>
    But what if I want the file to change with each refresh of the page what to I put...?


    Thanks in advance for any help you give
  • Beaver Bob
    Confirmed User
    • Aug 2005
    • 1099

    #2
    one quick way you could do that is create an array of all your links, and then generate a random number between 0 and the number of links - 1 and use that number.

    so like this if you had 3

    Code:
    <?php 
    $url[0] = 'http://www.fuck.you/fuckoff.html';
    $url[1] = 'http://www.suckmyballs.com';
    $url[2] = 'http://www.lickmynuts.com';
    
    $fuckingNumber = strval(rand()%3);
    
    include($url[$fuckingNumber]);
    ?>
    Spunky Dollars | Need Content?
    Paysite Owners: Protect Your Members Area with Strongbox

    361-574-229

    Comment

    • Jon Clark - BANNED FOR LIFE
      North Coast Pimp
      • Dec 2005
      • 9395

      #3
      Originally posted by Beaver Bob
      one quick way you could do that is create an array of all your links, and then generate a random number between 0 and the number of links - 1 and use that number.

      so like this if you had 3

      Code:
      <?php 
      $url[0] = 'http://www.fuck.you/fuckoff.html';
      $url[1] = 'http://www.suckmyballs.com';
      $url[2] = 'http://www.lickmynuts.com';
      
      $fuckingNumber = strval(rand()%3);
      
      include($url[$fuckingNumber]);
      ?>
      Thanks... But would I put replace "fuckingnumber" with the number of files there are?

      Comment

      • Cyrano
        Confirmed User
        • Apr 2006
        • 923

        #4
        No. 1234

        Comment

        • Beaver Bob
          Confirmed User
          • Aug 2005
          • 1099

          #5
          Originally posted by Jon Clark
          Thanks... But would I put replace "fuckingnumber" with the number of files there are?
          you would replace the 3 with the number of files you have.
          Spunky Dollars | Need Content?
          Paysite Owners: Protect Your Members Area with Strongbox

          361-574-229

          Comment

          • Napolean
            Misanthropic Egalitarian
            • Nov 2002
            • 4330

            #6
            Originally posted by Jon Clark
            Thanks... But would I put replace "fuckingnumber" with the number of files there are?
            Code:
            <?php
            $url[] = 'http://www.test1.com';
            $url[] = 'http://www.test2.com';
            $url[] = 'http://www.test3.com';
            
            $x= strval(rand()%count($url));
            
            include($url[$x]);
            ?>
            simpler version of the example above, only modification needed is to add more url's as you need them.
            HAH! FOUND IT FRIS

            Comment

            • Jon Clark - BANNED FOR LIFE
              North Coast Pimp
              • Dec 2005
              • 9395

              #7
              OK, I have tried to lines of code... Neither are working for me...

              First one is located at http://www.freepornation.com/test/index.php
              Code:
              <? $sl = rand(1,5);include ('1.htm'.$sl.'2.htm'.$sl.'3.htm'.$sl.'4.htm'.$sl.'5.htm'); ?>
              Second one is located here http://www.freepornation.com/test/index2.php
              Code:
              <?php 
              $url[0] = '1.htm';
              $url[1] = '2.htm';
              $url[2] = '3.htm';
              $url[3] = '4.htm';
              $url[4] = '5.htm';
              
              $no. 01234 = strval(rand()%5);
              
              include($url[$no. 01234]);
              ?>
              As you can see neither work

              Comment

              • Napolean
                Misanthropic Egalitarian
                • Nov 2002
                • 4330

                #8
                Originally posted by Jon Clark
                OK, I have tried to lines of code... Neither are working for me...

                First one is located at http://www.freepornation.com/test/index.php
                Code:
                <? $sl = rand(1,5);include ('1.htm'.$sl.'2.htm'.$sl.'3.htm'.$sl.'4.htm'.$sl.'5.htm'); ?>
                Second one is located here http://www.freepornation.com/test/index2.php
                Code:
                <?php 
                $url[0] = '1.htm';
                $url[1] = '2.htm';
                $url[2] = '3.htm';
                $url[3] = '4.htm';
                $url[4] = '5.htm';
                
                $no. 01234 = strval(rand()&#37;5);
                
                include($url[$no. 01234]);
                ?>
                As you can see neither work
                change "$no. 01234" to simply "$no"
                HAH! FOUND IT FRIS

                Comment

                • Jon Clark - BANNED FOR LIFE
                  North Coast Pimp
                  • Dec 2005
                  • 9395

                  #9
                  Originally posted by Napolean
                  Code:
                  <?php
                  $url[] = 'http://www.test1.com';
                  $url[] = 'http://www.test2.com';
                  $url[] = 'http://www.test3.com';
                  
                  $x= strval(rand()%count($url));
                  
                  include($url[$x]);
                  ?>
                  simpler version of the example above, only modification needed is to add more url's as you need them.

                  Worked perfect...

                  http://www.freepornation.com/test/index3.php

                  Thank you very much

                  Comment

                  • Dvae
                    Confirmed User
                    • Feb 2005
                    • 5326

                    #10
                    Originally posted by Jon Clark
                    OK, I have tried to lines of code... Neither are working for me...

                    First one is located at http://www.freepornation.com/test/index.php
                    Code:
                    <? $sl = rand(1,5);include ('1.htm'.$sl.'2.htm'.$sl.'3.htm'.$sl.'4.htm'.$sl.'5.htm'); ?>
                    Second one is located here http://www.freepornation.com/test/index2.php
                    Code:
                    <?php 
                    $url[0] = '1.htm';
                    $url[1] = '2.htm';
                    $url[2] = '3.htm';
                    $url[3] = '4.htm';
                    $url[4] = '5.htm';
                    
                    $no. 01234 = strval(rand()%5);
                    
                    include($url[$no. 01234]);
                    ?>
                    As you can see neither work
                    You should take the time to learn the basics of PHP.
                    .
                    .

                    Arguing with a troll is a lot like wrestling in the mud with a pig, after a couple of hours you realize the pig likes it.

                    Comment

                    • Napolean
                      Misanthropic Egalitarian
                      • Nov 2002
                      • 4330

                      #11
                      Originally posted by Jon Clark
                      Worked perfect...

                      http://www.freepornation.com/test/index3.php

                      Thank you very much
                      Cool
                      HAH! FOUND IT FRIS

                      Comment

                      • Beaver Bob
                        Confirmed User
                        • Aug 2005
                        • 1099

                        #12
                        Originally posted by Napolean
                        Code:
                        <?php
                        $url[] = 'http://www.test1.com';
                        $url[] = 'http://www.test2.com';
                        $url[] = 'http://www.test3.com';
                        
                        $x= strval(rand()%count($url));
                        
                        include($url[$x]);
                        ?>
                        simpler version of the example above, only modification needed is to add more url's as you need them.
                        nice modification man i shoulda thought of that but I was jus tryin to get him a quick basic idea.
                        Spunky Dollars | Need Content?
                        Paysite Owners: Protect Your Members Area with Strongbox

                        361-574-229

                        Comment

                        • Jon Clark - BANNED FOR LIFE
                          North Coast Pimp
                          • Dec 2005
                          • 9395

                          #13
                          Originally posted by Napolean
                          change "$no. 01234" to simply "$no"
                          And so did that....

                          http://www.freepornation.com/test/index2.php

                          Thanks






                          Now which one is better to use....


                          I plan on haveing several groups on one php page if that makes a difference

                          Comment

                          • sarettah
                            see you later, I'm gone
                            • Oct 2002
                            • 14346

                            #14
                            Damn, I didn't get to play
                            All cookies cleared!

                            Comment

                            • Jon Clark - BANNED FOR LIFE
                              North Coast Pimp
                              • Dec 2005
                              • 9395

                              #15
                              Originally posted by Beaver Bob
                              nice modification man i shoulda thought of that but I was jus tryin to get him a quick basic idea.

                              I thank you too

                              Comment

                              • Jon Clark - BANNED FOR LIFE
                                North Coast Pimp
                                • Dec 2005
                                • 9395

                                #16
                                Originally posted by Dvae
                                You should take the time to learn the basics of PHP.

                                You are more then correct and it is in my plans, but managing the designers, clients and working on this new program I hardly have time for anything at all

                                Comment

                                • Beaver Bob
                                  Confirmed User
                                  • Aug 2005
                                  • 1099

                                  #17
                                  Originally posted by Jon Clark
                                  And so did that....

                                  http://www.freepornation.com/test/index2.php

                                  Thanks






                                  Now which one is better to use....


                                  I plan on haveing several groups on one php page if that makes a difference
                                  his is better because it counts the number of elements in the array for you. but both will do the job.
                                  Spunky Dollars | Need Content?
                                  Paysite Owners: Protect Your Members Area with Strongbox

                                  361-574-229

                                  Comment

                                  • Jon Clark - BANNED FOR LIFE
                                    North Coast Pimp
                                    • Dec 2005
                                    • 9395

                                    #18
                                    Originally posted by sarettah
                                    Damn, I didn't get to play

                                    I am sure there will be a next time... I am a total newb at alot of things and I am not scared to ask for help

                                    Comment

                                    • Sly
                                      Let's do some business!
                                      • Sep 2004
                                      • 31379

                                      #19
                                      Originally posted by Jon Clark
                                      You are more then correct and it is in my plans, but managing the designers, clients and working on this new program I hardly have time for anything at all
                                      For starters, you can't have a space in variable names.
                                      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

                                      • Beaver Bob
                                        Confirmed User
                                        • Aug 2005
                                        • 1099

                                        #20
                                        Originally posted by Jon Clark
                                        I thank you too
                                        no prob. one of the very basic things about PHP is you can't have spaces in your variable names or periods and certain other special characters that are used as operators.
                                        Spunky Dollars | Need Content?
                                        Paysite Owners: Protect Your Members Area with Strongbox

                                        361-574-229

                                        Comment

                                        • Jon Clark - BANNED FOR LIFE
                                          North Coast Pimp
                                          • Dec 2005
                                          • 9395

                                          #21
                                          Originally posted by Beaver Bob
                                          his is better because it counts the number of elements in the array for you. but both will do the job.

                                          Thanks Bob... I will play around with them both and see which ends up working best for my application

                                          Comment

                                          • Kaylum
                                            Confirmed User
                                            • Aug 2005
                                            • 465

                                            #22


                                            way to go jon, work the php!
                                            -- "You can't stop ingenuity, trust me.."

                                            Comment

                                            • Jon Clark - BANNED FOR LIFE
                                              North Coast Pimp
                                              • Dec 2005
                                              • 9395

                                              #23
                                              Originally posted by Kaylum


                                              way to go jon, work the php!

                                              Thanks Kaylum, I am trying

                                              Comment

                                              • Domain Distribution
                                                Ask me about negative cash flow
                                                • May 2006
                                                • 539

                                                #24
                                                The only gracious way to accept an insult is to ignore it.
                                                Artifical Intelligence AIM Bot ~ $199.00
                                                [email protected]
                                                238102273

                                                Comment

                                                Working...