...

View Full Version : Includes for beginners



Beeper
07-08-2005, 11:09 AM
Can I do this:

<a href="<?php include("includes/newslink.inc"); ?>">View story</a>

and furthermore:

can I call an include 'newslink.txt' and then do this:

<a href="<?php include("includes/newslink.txt"); ?>">View story</a>

Nightfire
07-08-2005, 11:23 AM
Try it...


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

Beeper
07-08-2005, 11:27 AM
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)

gsnedders
07-08-2005, 12:55 PM
@readfile('includes/newslink.inc');

Beeper
07-08-2005, 01:08 PM
so:


<a href="<?php @readfile('includes/newslink.inc'); ?>">View story</a>

???

gsnedders
07-08-2005, 03:53 PM
Yeah.

Beeper
07-08-2005, 04:07 PM
Hi Error 404,

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

So my include just contains:

http://www.domain.com/directory/file.htm

gsnedders
07-08-2005, 04:13 PM
Yeah.

Beeper
07-08-2005, 04:17 PM
Thank you - you're very helpful (but not very communicative :p)

gsnedders
07-08-2005, 04:30 PM
Thank you - you're very helpful (but not very communicative :p)
Yeah. :p

Kurashu
07-08-2005, 07:26 PM
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)?

Beeper
07-11-2005, 11:11 AM
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

<a href="<?php @readfile('includes/newslink.txt'); ?>">View story</a>

Include contents

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? :eek:

delinear
07-11-2005, 12:41 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum