News:

Click here for Toll-Free Service for your business starting at $2.00 per month

Main Menu

Some assistance please.....to do with directories and linking to files in them.

Started by Paris, February 17, 2006, 06:46:51 AM

Previous topic - Next topic

Paris

okay, well i just created a few new directories for my layouts(linkware)and im trying to link to the images and pages from my root directory into the pages in my new directories.

For example:
one directory is "divs" and the page im trying to create inside of it is called "divlayers.php". Im trying to make it have the same layout as the pages in my root directory have. I use the php include code to include the header and footer(layout codes)codes into the pages but i can't figure out how to link to images and pages in other directories.

like for images ive tried this:
(Example)
("/image.gif")
and
("root/image..gif")
and
("root/divs/image.gif")

and for links:
(Example)
<?php include('root/header.php'); ?>(for the header and footer)
or
<?php include('/header.php'); ?>
or
<a href="root/divs/divlayers.php">۞ Div - Layers</a><br>
or
<a href="/divs/divlayers.php">۞ Div - Layers</a><br>

it never works.....please tell me what im doing wrong and what i can do to fix it.

sixthcrusifix

Quote from: paris on February 17, 2006, 06:46:51 AM
okay, well i just created a few new directories for my layouts(linkware)and im trying to link to the images and pages from my root directory into the pages in my new directories.

For example:
one directory is "divs" and the page im trying to create inside of it is called "divlayers.php". Im trying to make it have the same layout as the pages in my root directory have. I use the php include code to include the header and footer(layout codes)codes into the pages but i can't figure out how to link to images and pages in other directories.

like for images ive tried this:
(Example)
("/image.gif")
and
("root/image..gif")
and
("root/divs/image.gif")

and for links:
(Example)
<?php include('root/header.php'); ?>(for the header and footer)
or
<?php include('/header.php'); ?>
or
<a href="root/divs/divlayers.php">۞ Div - Layers</a><br>
or
<a href="/divs/divlayers.php">۞ Div - Layers</a><br>

it never works.....please tell me what im doing wrong and what i can do to fix it.


are you from a differen counrty than US/Canada? Because I dunno what this: ۞ is, I see a weird circly thing.


I take it you're a litte new to HTML? You might wanna delve more into it before you really try PHP, Simply because PHP is useless if you don't have an understanding of the visual output. PHP Processes everything but we still use HTML to display everything.


for linking: Either use the full http:// address or put "./" In front, like this:


<a href="./Directory/file.php">Blah</a>
< a href="http://yourdomain.com/Directory/file.php">Blah</a>


Also PHP include can't include images. You need HTML to display an image:

<image source="http://directoryofimage.gif">

If you try to incude an image you'll just get an error because PHP will read the image and try to somehow include it (as in text). You could include a page that displays an image but that would be silly, don't rely too much on include try to use as much HTML as possible and only use PHP when you have to, Using PHP beyond it's needs and just doing everything in it is, in teh long run, a waste of resourses and time coding.

Visite me website at http://www.sixthcrusifix.com

lotsofish

Quote from: paris on February 17, 2006, 06:46:51 AM
okay, well i just created a few new directories for my layouts(linkware)and im trying to link to the images and pages from my root directory into the pages in my new directories.

For example:
one directory is "divs" and the page im trying to create inside of it is called "divlayers.php". Im trying to make it have the same layout as the pages in my root directory have. I use the php include code to include the header and footer(layout codes)codes into the pages but i can't figure out how to link to images and pages in other directories.

like for images ive tried this:
(Example)
("/image.gif")
and
("root/image..gif")
and
("root/divs/image.gif")

and for links:
(Example)
<?php include('root/header.php'); ?>(for the header and footer)
or
<?php include('/header.php'); ?>
or
<a href="root/divs/divlayers.php">۞ Div - Layers</a><br>
or
<a href="/divs/divlayers.php">۞ Div - Layers</a><br>

it never works.....please tell me what im doing wrong and what i can do to fix it.

Hi there.

When you sign into your ftp account, it looks like it is the root ( / ) but actually, it is your own subdirectory (in your case, /fpgs/fpgshttpd/paris/ )  When using PHP, it isn't restricted to just your subdirectory, so, when you say include ("/header.php"); what you really meant to say was include("/fpgs/fpgshttpd/paris/header.php");  Alternatively, you could use the relative ( .. ) to go up a directory.  include ("../header.php");

On the web, since you are using the freepgs.com/paris/ url (right, or do you have a domain?) if you use /, your browser will be looking for a file from the freepgs.com/ directory instead of freepgs.com/paris/  When you use <a href="/divs/divlayers.php"> you are telling your browser freepgs.com/divs/divlayers.php, which is wrong.   Use <a href="/paris/divs/divlayers.php"> instead.

Hope this helps.

Andrew



sixthcrusifix

Quote from: lotsofish on February 17, 2006, 08:12:09 AM
Quote from: paris on February 17, 2006, 06:46:51 AM
okay, well i just created a few new directories for my layouts(linkware)and im trying to link to the images and pages from my root directory into the pages in my new directories.

For example:
one directory is "divs" and the page im trying to create inside of it is called "divlayers.php". Im trying to make it have the same layout as the pages in my root directory have. I use the php include code to include the header and footer(layout codes)codes into the pages but i can't figure out how to link to images and pages in other directories.

like for images ive tried this:
(Example)
("/image.gif")
and
("root/image..gif")
and
("root/divs/image.gif")

and for links:
(Example)
<?php include('root/header.php'); ?>(for the header and footer)
or
<?php include('/header.php'); ?>
or
<a href="root/divs/divlayers.php">۞ Div - Layers</a><br>
or
<a href="/divs/divlayers.php">۞ Div - Layers</a><br>

it never works.....please tell me what im doing wrong and what i can do to fix it.

Hi there.

When you sign into your ftp account, it looks like it is the root ( / ) but actually, it is your own subdirectory (in your case, /fpgs/fpgshttpd/paris/ )  When using PHP, it isn't restricted to just your subdirectory, so, when you say include ("/header.php"); what you really meant to say was include("/fpgs/fpgshttpd/paris/header.php");  Alternatively, you could use the relative ( .. ) to go up a directory.  include ("../header.php");

On the web, since you are using the freepgs.com/paris/ url (right, or do you have a domain?) if you use /, your browser will be looking for a file from the freepgs.com/ directory instead of freepgs.com/paris/  When you use <a href="/divs/divlayers.php"> you are telling your browser freepgs.com/divs/divlayers.php, which is wrong.   Use <a href="/paris/divs/divlayers.php"> instead.

Hope this helps.

Andrew




or  <a href="./divs/divlayers.php"> :P


Also, before teh file using the relative paths to include didn't work, neitehr did using the http://, it's best just to get into the habit of using /fpgs/fpgshttpd/username/

But in case you never know if you're not going to use freepgs forever or is we have a problem and change the folder name, I reccoment making a php file in teh root directory that has some very common variable declarations and including it in all fils. Amung these I would include a simple variable with that value in it so that you cna just change that one variable on that one page if you move sites and don't wanna change every single include() in your site.
Visite me website at http://www.sixthcrusifix.com

webzone (archived)

QuoteBut in case you never know if you're not going to use freepgs forever or is we have a problem and change the folder name, I reccoment making a php file in teh root directory that has some very common variable declarations and including it in all fils. Amung these I would include a simple variable with that value in it so that you cna just change that one variable on that one page if you move sites and don't wanna change every single include() in your site.

Or you could simply use $_SERVER["DOCUMENT_ROOT"]

sixthcrusifix

Quote from: webzone on February 17, 2006, 09:59:16 PM
QuoteBut in case you never know if you're not going to use freepgs forever or is we have a problem and change the folder name, I reccoment making a php file in teh root directory that has some very common variable declarations and including it in all fils. Amung these I would include a simple variable with that value in it so that you cna just change that one variable on that one page if you move sites and don't wanna change every single include() in your site.

Or you could simply use $_SERVER["DOCUMENT_ROOT"]

oh cool never heard of it. but when you use things like echo() or include() you can't use arrays.

like

include("$_SERVER[\"DOCUMENT_ROOT\"]");

include("$_SERVER[\"DOCUMENT_ROOT\"]");

include("$_SERVER['DOCUMENT_ROOT']");



all return errors.


QuoteParse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /fpgs/fpgshttpd/sixthcrusifix/testpage.php on line 1

so you'd have to set a veriable (not array) to $_SERVER['DOCUMENT_ROOT'] anyway.
Visite me website at http://www.sixthcrusifix.com

webzone (archived)

include($_SERVER['DOCUMENT_ROOT'].'/file.php');

translates, for me, to

include('/fpgs/fpgshttpd/webzone/file.php');

An array must be placed outside the " and added to the rest of the string using a concatenation operator (.)

sixthcrusifix

Quote from: webzone on February 18, 2006, 02:42:50 AM
include($_SERVER['DOCUMENT_ROOT'].'/file.php');

translates, for me, to

include('/fpgs/fpgshttpd/webzone/file.php');

An array must be placed outside the " and added to the rest of the string using a concatenation operator (.)

oh I see, I guess that's better for include and stuff. But Occasionaly I echo a lot of text at a time and arrays realy annoy me.
Visite me website at http://www.sixthcrusifix.com

neosquared

Quote from: sixthcrusifix on February 17, 2006, 07:17:26 AM
Also PHP include can't include images. You need HTML to display an image:

<image source="http://directoryofimage.gif">
A couple things I feel I should point out here -
First, that's not how you do an image.  The proper code is this:
<img src="directoryofimage.gif">

Second, the URL http://directoryofimage.gif would tell the browser to try and load the WEBSITE directoryofimage.gif into the spot for the image, treating the .gif part as it would .com, .net, .org and the like. (i.e http://www.directoryofimage.gif/ )  You ONLY put http:// at the front of the URL when you are including the domain, like this:
<img src="http://www.example.com/directoryofimage.gif">
Otherwise, it will make things crash and burn.
Don't take servers for granted.
Everything is flammable, if you get it hot enough.
Visit my website!  It'll make you cooler!

sixthcrusifix

Quote from: neosquared on February 27, 2006, 07:56:27 PM
Quote from: sixthcrusifix on February 17, 2006, 07:17:26 AM
Also PHP include can't include images. You need HTML to display an image:

<image source="http://directoryofimage.gif">
A couple things I feel I should point out here -
First, that's not how you do an image.  The proper code is this:
<img src="directoryofimage.gif">

Second, the URL http://directoryofimage.gif would tell the browser to try and load the WEBSITE directoryofimage.gif into the spot for the image, treating the .gif part as it would .com, .net, .org and the like. (i.e http://www.directoryofimage.gif/ )  You ONLY put http:// at the front of the URL when you are including the domain, like this:
<img src="http://www.example.com/directoryofimage.gif">
Otherwise, it will make things crash and burn.


Actually for your information "image source" is the original code for including images and works perfectly fine. "img src" is an abbreviation and also works.

And I think that you're being a little annoying. I'm not a total complete retard, NO offence but do you honestly hear what you're telling me because I'm extremely offended.

directoryofimage - That is wherever teh image is, I dunno where this guy has his image, but whatever the full directory path is he should put it there.

The directory: "freepgs.com/username/poo.gif"

So he'd stick that in place of "directoryofimage". Sorry I didn't include the website I don't know what his domain name is so I just stuck a word in there. I know that you probably think that I was saying just to stick a directory in there and not care about the domain name, That would be wrong. However if you knock off the http you can just use a directory (called a relative path).

So I actually do understand what you were talking about, my message was not incorrect but not clear enough (upon looking back I realise).


EDIT: I truly thought "image source" was valid but I must have been thinking of "Background source". However I distinctly remember using it and it working, I can only guess that my browser was smart enough (After all firefox will automatically convert "<image>" to "<img>".

Either way it is important to know what the abreviations are for. But I swear on a stack of bibles I've used "<image source" before.

Visite me website at http://www.sixthcrusifix.com