Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Posts
    133
    Thanks
    2
    Thanked 0 Times in 0 Posts

    side bar/source file?

    Could someone help me make a source file that can be listed on a bunch of different pages?

    I want to have a side bar with a list of picture links on a bunch of different pages.

    But I don't want to have to add the list to each page manually, ya know?

    Also, is there a way to have a button that switches the 'source file' to another source file?

    What I want to do is, have a sidebar with a list of links that lead to different videos on my site. Almost all the pages will have the sidebar list on it. And I want a button at the top of the list that can change the list to a different list that I've compiled.

    I've been told that this involves PHP? I'm only familiar with HTML and CSS though.

  • #2
    Regular Coder
    Join Date
    Sep 2010
    Posts
    331
    Thanks
    9
    Thanked 6 Times in 6 Posts
    You could try putting the links in a database table and then use php to select the links from the database

  • #3
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,899
    Thanks
    15
    Thanked 226 Times in 226 Posts
    To write a file to a page with PHP you use the include function. Just format the file exactly they way you want the code of the page to be, indenting and everything.
    PHP Code:
    <?php include "movie_menu.txt"?>
    That file will be written verbatim to the page. Do not put php tags around the text or the PHP engine will try to execute it. You don't need to name it .php either. If you have multiple lists of movies it might be simpler to just make multiple pages and make the link above the list refer to another page with the include of another list. The reason for that is reusing the same page for another list involves making a server call which is another level of complexity. That will get you going and will work fine. After you've developed more PHP skills you can make a more automated version which will build the links from a simple listing and paginate them.

  • #4
    Regular Coder
    Join Date
    Aug 2010
    Posts
    133
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I changed the html file to a .php extension, and created the pamlist.txt file in root directory/solo/

    When I put in the code into the .php file where the list should appear;

    Code:
    <? php include "/solo/pamlist.txt"; ?>
    This warning comes up on the page (no list )

    Code:
    Warning: include(/solo/listpam.txt) [function.include]: failed to open stream: No such file or directory in /home/njfailc1/public_html/solo/index.php on line 64
    
    Warning: include() [function.include]: Failed opening '/solo/listpam.txt' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/njfailc1/public_html/solo/index.php on line 64


    Its @ njfail.com/solo

  • #5
    Regular Coder poyzn's Avatar
    Join Date
    Nov 2010
    Posts
    266
    Thanks
    2
    Thanked 61 Times in 61 Posts
    Quote Originally Posted by njfail View Post
    When I put in the code into the .php file where the list should appear;
    it appears exactly where you're putting include

    check the file if it really exists and try this path
    PHP Code:
    include $_SERVER['DOCUMENT_ROOT'] . '/solo/pamlist.txt'
    Last edited by poyzn; 11-13-2010 at 07:19 PM.

  • #6
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,899
    Thanks
    15
    Thanked 226 Times in 226 Posts
    poyzn covered it, but simply omitting the first slash may have made it work, depending on the server settings, the slash in front usually refers to the root of the drive and not the root of the server.

  • #7
    Regular Coder
    Join Date
    Aug 2010
    Posts
    133
    Thanks
    2
    Thanked 0 Times in 0 Posts
    When I use:
    (I've tried with and without the beginning '/')

    Code:
    <?php include $_SERVER['DOCUMENT_ROOT'] . '/solo/pamlist.txt'; ?>
    This error occurs.

    Code:
    Warning: include(/home/njfailc1/public_html/solo/pamlist.txt) [function.include]: failed to open stream: No such file or directory in /home/njfailc1/public_html/solo/index.php on line 64
    
    Warning: include() [function.include]: Failed opening '/home/njfailc1/public_html/solo/pamlist.txt' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/njfailc1/public_html/solo/index.php on line 64
    But thats exactly where the file is...
    Attached Thumbnails Attached Thumbnails side bar/source file?-phphelp.jpg  
    Last edited by njfail; 11-13-2010 at 07:44 PM.

  • #8
    Regular Coder poyzn's Avatar
    Join Date
    Nov 2010
    Posts
    266
    Thanks
    2
    Thanked 61 Times in 61 Posts
    check the file name, should be
    PHP Code:
    include $_SERVER['DOCUMENT_ROOT'] . '/solo/listpam.txt'

  • #9
    Regular Coder
    Join Date
    Aug 2010
    Posts
    133
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Browsing my server host's control panel, I found this in the php configuration menu... can any tell me what it means and how it could affect my php code?

    Paths and Directories
    include_path
    Windows:
    "\path1;\path2" c:\php\includes"
    .:/usr/lib/php:/usr/local/lib/php

  • #10
    Regular Coder
    Join Date
    Aug 2010
    Posts
    133
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by poyzn View Post
    check the file name, should be
    PHP Code:
    include $_SERVER['DOCUMENT_ROOT'] . '/solo/listpam.txt'
    When I do it without the <?php ?> tags it just says what you wrote in plain text..

  • #11
    Regular Coder poyzn's Avatar
    Join Date
    Nov 2010
    Posts
    266
    Thanks
    2
    Thanked 61 Times in 61 Posts
    Quote Originally Posted by njfail View Post
    Browsing my server host's control panel, I found this in the php configuration menu... can any tell me what it means and how it could affect my php code?
    You can define custom include paths with set_include_path to specific directories on your site. That will allow you to include files from that directories without writing full path to the file

  • #12
    Regular Coder poyzn's Avatar
    Join Date
    Nov 2010
    Posts
    266
    Thanks
    2
    Thanked 61 Times in 61 Posts
    Quote Originally Posted by njfail View Post
    When I do it without the <?php ?> tags it just says what you wrote in plain text..
    You should always wrap php-code with <?php ... ?>

  • #13
    Regular Coder
    Join Date
    Aug 2010
    Posts
    133
    Thanks
    2
    Thanked 0 Times in 0 Posts
    any other ideas of what the problem could be? I've checked the names several files, they're spelled correctly, all lowercase letters.

  • #14
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,899
    Thanks
    15
    Thanked 226 Times in 226 Posts
    You're on a Windows server so you may need to use backward slashes instead of forward ones ( most likely ), however you can just put the file in the includes folder and see if my original code, without any slashes works, or with includes\ . Makes it tough when your home server is Windows and the remote is Linux/BSD.

  • #15
    Regular Coder
    Join Date
    Aug 2010
    Posts
    133
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by DrDOS View Post
    You're on a Windows server so you may need to use backward slashes instead of forward ones ( most likely ), however you can just put the file in the includes folder and see if my original code, without any slashes works, or with includes\ . Makes it tough when your home server is Windows and the remote is Linux/BSD.
    That returns this error:

    Code:
    Warning: include(\solo\listpam.txt) [function.include]: failed to open stream: No such file or directory in /home/njfailc1/public_html/solo/index.php on line 64
    
    Warning: include(\solo\listpam.txt) [function.include]: failed to open stream: No such file or directory in /home/njfailc1/public_html/solo/index.php on line 64
    
    Warning: include() [function.include]: Failed opening '\solo\listpam.txt' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/njfailc1/public_html/solo/index.php on line 64
    Where is this file directory located at?? ".:/usr/lib/php:/usr/local/lib/php"


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •