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.
Results 1 to 13 of 13
  1. #1
    New Coder
    Join Date
    Jun 2005
    Location
    London
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Includes for beginners

    Can I do this:
    Code:
    <a href="<?php include("includes/newslink.inc"); ?>">View story</a>
    and furthermore:

    can I call an include 'newslink.txt' and then do this:
    Code:
    <a href="<?php include("includes/newslink.txt"); ?>">View story</a>
    Last edited by Beeper; 07-08-2005 at 11:10 AM. Reason: Code tags
    Never argue with an idiot.
    They just drag you down to their level...
    ...and beat you with experience.


    -----------------------------------------

    That which is static and repetitive is boring.
    That which is dynamic and random is confusing.
    In between lies art.

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Try it...


    But it won't work, you'll just be linking up a file, not the url of the file

  • #3
    New Coder
    Join Date
    Jun 2005
    Location
    London
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OK, so, how do I make an include that is a url that can be used as a link with no html in it (because the user of this system is even more of an imbecile than I am)
    Never argue with an idiot.
    They just drag you down to their level...
    ...and beat you with experience.


    -----------------------------------------

    That which is static and repetitive is boring.
    That which is dynamic and random is confusing.
    In between lies art.

  • #4
    Senior Coder gsnedders's Avatar
    Join Date
    Jan 2004
    Posts
    2,340
    Thanks
    1
    Thanked 7 Times in 7 Posts
    PHP Code:
    @readfile('includes/newslink.inc'); 

  • #5
    New Coder
    Join Date
    Jun 2005
    Location
    London
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    so:

    Code:
    <a href="<?php @readfile('includes/newslink.inc'); ?>">View story</a>
    ???
    Never argue with an idiot.
    They just drag you down to their level...
    ...and beat you with experience.


    -----------------------------------------

    That which is static and repetitive is boring.
    That which is dynamic and random is confusing.
    In between lies art.

  • #6
    Senior Coder gsnedders's Avatar
    Join Date
    Jan 2004
    Posts
    2,340
    Thanks
    1
    Thanked 7 Times in 7 Posts
    Yeah.

  • #7
    New Coder
    Join Date
    Jun 2005
    Location
    London
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Error 404,

    to confirm (sorry about this but the site is live)

    So my include just contains:
    Code:
    http://www.domain.com/directory/file.htm
    Never argue with an idiot.
    They just drag you down to their level...
    ...and beat you with experience.


    -----------------------------------------

    That which is static and repetitive is boring.
    That which is dynamic and random is confusing.
    In between lies art.

  • #8
    Senior Coder gsnedders's Avatar
    Join Date
    Jan 2004
    Posts
    2,340
    Thanks
    1
    Thanked 7 Times in 7 Posts
    Yeah.

  • #9
    New Coder
    Join Date
    Jun 2005
    Location
    London
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you - you're very helpful (but not very communicative )
    Never argue with an idiot.
    They just drag you down to their level...
    ...and beat you with experience.


    -----------------------------------------

    That which is static and repetitive is boring.
    That which is dynamic and random is confusing.
    In between lies art.

  • #10
    Senior Coder gsnedders's Avatar
    Join Date
    Jan 2004
    Posts
    2,340
    Thanks
    1
    Thanked 7 Times in 7 Posts
    Quote Originally Posted by Beeper
    Thank you - you're very helpful (but not very communicative )
    Yeah.

  • #11
    Regular Coder
    Join Date
    Aug 2004
    Location
    The US of A
    Posts
    767
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Beeper
    OK, so, how do I make an include that is a url that can be used as a link with no html in it (because the user of this system is even more of an imbecile than I am)
    I think you have the wrong idea of what you want.

    You want to link to a story, right? If you explain your backend a little more, we can help you more.

    Do you have a SQL database with this information? If not can you get one?
    Is this a premade script or something that you made?
    Do you have an example of what you want (other than the include example)?

  • #12
    New Coder
    Join Date
    Jun 2005
    Location
    London
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OK

    there is no back end. I could make one but then it gets more complicated tbh I can't be arsed.

    So the problem is I have some information that is spread across all the pages that needs to be updated regularly.

    Share price
    Share date
    News headline
    News story
    and link

    The user uses contribute already on their website and has asked me to help them because currently they have to update that information on every page (250+) so I thought a simple way would be to create an include.

    So they have 5 includes as editable text files in contribute (see above)

    Now I just <?php include("includes/shareprice.txt"); ?>

    However, because this is a live site and I don't want to break it I was asking how to make the link work as I wasn't sure that it would doing it the way I had envisioned (thankfully my inkling proved correct)

    So now Error 404 suggested

    Include link
    Code:
    <a href="<?php @readfile('includes/newslink.txt'); ?>">View story</a>
    Include contents
    Code:
    http://www.domain.com/directory/file.htm
    Now I just need to make sure that I can use include.txt rather than include.inc

    Also some one mentioned I should call it include.txt.php for security reasons but I am not sure that is too important... or is it?
    Never argue with an idiot.
    They just drag you down to their level...
    ...and beat you with experience.


    -----------------------------------------

    That which is static and repetitive is boring.
    That which is dynamic and random is confusing.
    In between lies art.

  • #13
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can have any extension you like if all you're doing is outputting the contents. You only need .php if you have some php inside the include file you want to run or if, as suggested, you need to hide the contents of the file from people. In your case, for simple stuff like this it sounds like that's not too important.


  •  

    Posting Permissions

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