+ Reply to Thread
Results 1 to 10 of 10

Thread: How do i use php

  1. #1
    remnightfall is offline x10Hosting Member remnightfall is an unknown quantity at this point
    Join Date
    Feb 2010
    Posts
    20

    How do i use php

    Okay sory if this has already been answered or if its in the wrong section, the search button isn't working.


    Okay my problem is i want to be able to edit every single page at once. And i googled it, and it said there was a thing called PHP, and i tried it on x10hosting and it either doesn't work for me or im not doing it wrong.


    This is my website and if you look in the top left corner it will say *Recent forum posts * and i realized i would have to go to every single page to change that, so if someone knows how to use PHP please explain to me, cause im really really confused.

    http://bluehedgehog.pcriot.com/index.php (under construction nothing works right now)
    Last edited by remnightfall; 03-25-2010 at 03:27 PM.

  2. #2
    techairlines's Avatar
    techairlines is offline x10 Flyer techairlines has much to be proud oftechairlines has much to be proud of
    Join Date
    Jul 2009
    Location
    New York City
    Posts
    2,853

    Re: How do i use php

    You can try using PHP includes for that function.

    Create a file with the information/code you want to include there and name the file recent.php. On the main pages, replace the recent posts code with:

    Code:
    <?php include("recent.php"); ?>
    Name all your website pages .php rather than .html. Upload all the files to the same directory.

    Example:

    On your main index page, have the following code:
    Code:
    <html>
    <body>
    <?php include ("recent.php")?>
    <p>Welcome!</p>
    </body>
    </html>
    On your recent.php file, have the following code:
    Code:
    <div id="recentrecord"><img width="229" height="70" src="recentforumposts2.png" title="" alt="">
    <ul>
    <li>test</li>
    <li>this is just a test</li>
    <li>test</li>
    <li>mhmm still a test<br>
    </li>
    <li>testomg</li></ul>
    <div class="clearthis">&nbsp;</div></div>
    When others view your website, they will load the following source code:
    Code:
    <html>
    <body>
    <div id="recentrecord"><img width="229" height="70" src="recentforumposts2.png" title="" alt="">
    <ul>
    <li>test</li>
    <li>this is just a test</li>
    <li>test</li>
    <li>mhmm still a test<br>
    </li>
    <li>testomg</li></ul>
    <div class="clearthis">&nbsp;</div></div>
    <p>Welcome!</p>
    </body>
    </html>
    A full detailed tutorial on PHP Includes can be found at: http://www.w3schools.com/PHP/php_includes.asp
    Last edited by techairlines; 03-25-2010 at 03:26 PM.
    Best regards,
    Brian Yang - TechAirlines


    How am I doing? Click the star button at the bottom left to rate this post. Thanks.
    Terms of Service | Account Portal | Wiki

  3. #3
    remnightfall is offline x10Hosting Member remnightfall is an unknown quantity at this point
    Join Date
    Feb 2010
    Posts
    20

    Re: How do i use php

    Iv tried that it dosnt do anything.

  4. #4
    Livewire's Avatar
    Livewire is offline Abuse Compliance Officer Livewire is a glorious beacon of lightLivewire is a glorious beacon of light
    Join Date
    Jun 2005
    Location
    Behind a keyboard.
    Posts
    8,998

    Re: How do i use php

    PHP is functioning on the x10 servers so you'll want to try a tutorial, but there's at least one big key point I should make here.

    PHP doesn't work if the page extension is .html (such as index.html) - it has to be index.php or the server will not attempt to parse the php code correctly. That might've been causing your problems where it wasn't working


    EDIT: Oh, and you have to code the file it's including; when you include recent.php, you have to have a recent.php there for it to include.
    Last edited by Livewire; 03-25-2010 at 03:26 PM.


    TOS breakers will be suspended regardless of race, creed, national origin, hair color, or favorite food. Thanks for your understanding!

  5. #5
    remnightfall is offline x10Hosting Member remnightfall is an unknown quantity at this point
    Join Date
    Feb 2010
    Posts
    20

    Re: How do i use php

    Quote Originally Posted by techairlines View Post
    you can try using php includes for that function.

    Create a file with the information/code you want to include there and name the file recent.php. On the main pages, replace the recent posts code with:

    Code:
    <?php include("recent.php"); ?>
    name all your website pages .php rather than .html. Upload all the files to the same directory.

    example:

    on your main index page, have the following code:
    Code:
    <html>
    <body>
    <?php include ("recent.php")?>
    <p>welcome!</p>
    </body>
    </html>
    on your recent.php file, have the following code:
    Code:
    <div id="recentrecord"><img width="229" height="70" src="recentforumposts2.png" title="" alt="">
    <ul>
    <li>test</li>
    <li>this is just a test</li>
    <li>test</li>
    <li>mhmm still a test<br>
    </li>
    <li>testomg</li></ul>
    <div class="clearthis">&nbsp;</div></div>
    when others view your website, they will load the following source code:
    Code:
    <html>
    <body>
    <div id="recentrecord"><img width="229" height="70" src="recentforumposts2.png" title="" alt="">
    <ul>
    <li>test</li>
    <li>this is just a test</li>
    <li>test</li>
    <li>mhmm still a test<br>
    </li>
    <li>testomg</li></ul>
    <div class="clearthis">&nbsp;</div></div>
    <p>welcome!</p>
    </body>
    </html>
    a full detailed tutorial on php includes can be found at: http://www.w3schools.com/php/php_includes.asp




    thank you!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! so mucchhhhhh

  6. #6
    remnightfall is offline x10Hosting Member remnightfall is an unknown quantity at this point
    Join Date
    Feb 2010
    Posts
    20

    Re: How do i use php

    Quote Originally Posted by Livewire View Post
    PHP is functioning on the x10 servers so you'll want to try a tutorial, but there's at least one big key point I should make here.

    PHP doesn't work if the page extension is .html (such as index.html) - it has to be index.php or the server will not attempt to parse the php code correctly. That might've been causing your problems where it wasn't working


    EDIT: Oh, and you have to code the file it's including; when you include recent.php, you have to have a recent.php there for it to include.
    Okay i did that

  7. #7
    remnightfall is offline x10Hosting Member remnightfall is an unknown quantity at this point
    Join Date
    Feb 2010
    Posts
    20

    Re: How do i use php

    Ohkay I did everything i was suppose to do...Now all i see is test tes tes test and "Welcome" and recent forum post banner? is this suppose to happen

  8. #8
    Thomas David Bell is offline x10Hosting Member Thomas David Bell is an unknown quantity at this point
    Join Date
    Mar 2010
    Posts
    5

    Re: How do i use php

    Quote Originally Posted by remnightfall View Post
    Ohkay I did everything i was suppose to do...Now all i see is test tes tes test and "Welcome" and recent forum post banner? is this suppose to happen
    If you coped and pasted his PHP script, then yes.

  9. #9
    techairlines's Avatar
    techairlines is offline x10 Flyer techairlines has much to be proud oftechairlines has much to be proud of
    Join Date
    Jul 2009
    Location
    New York City
    Posts
    2,853

    Re: How do i use php

    Quote Originally Posted by remnightfall View Post
    thank you!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! so mucchhhhhh
    You're welcome. Glad I could help.

    Quote Originally Posted by remnightfall View Post
    Ohkay I did everything i was suppose to do...Now all i see is test tes tes test and "Welcome" and recent forum post banner? is this suppose to happen
    My code snippet I posted above was just for the Recent Post area. Remember to add the rest of the site's content to the code for each page. If you have any more dynamic content, you can always create more PHP files and include more.
    Best regards,
    Brian Yang - TechAirlines


    How am I doing? Click the star button at the bottom left to rate this post. Thanks.
    Terms of Service | Account Portal | Wiki

  10. #10
    remnightfall is offline x10Hosting Member remnightfall is an unknown quantity at this point
    Join Date
    Feb 2010
    Posts
    20

    Re: How do i use php

    Ohkay thanks xD

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers