The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

2 Pages V < 1 2  
Reply to this topicStart new topic
> php include from a different directory?
Trafalgar
post Jul 18 2009, 10:35 AM
Post #21





Group: Members
Posts: 3
Joined: 18-July 09
Member No.: 9,175



I tried to use this command (<?php include("header.php"); ?> and it worked wonders. However it seems like it does not include images properly. Is there a fix for this?

This post has been edited by Trafalgar: Jul 18 2009, 10:37 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jul 18 2009, 10:52 AM
Post #22


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Remember that if you use relative URLs in the src they become relative to the including file. No trick needed. smile.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Trafalgar
post Jul 18 2009, 01:09 PM
Post #23





Group: Members
Posts: 3
Joined: 18-July 09
Member No.: 9,175



I'm trying to call public_html/header.php to one of my files located in public_html/forums. When I do this however, it is locating images from public_html/forums/images and not public_html/images. All the images header.php uses are of course in public_html/images. So how do I fix it so that it looks for images in public_html/images instead of public_html/forums/images?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jul 18 2009, 01:27 PM
Post #24


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Use absolute (http://...) or root relative (/...) URLs for images and the like.
http://htmlhelp.com/faq/html/basics.html#relative-url
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Trafalgar
post Jul 18 2009, 01:30 PM
Post #25





Group: Members
Posts: 3
Joined: 18-July 09
Member No.: 9,175



Thanks for the help pandy, everything makes sense now.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jul 18 2009, 03:08 PM
Post #26


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Good! happy.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Jul 19 2009, 03:06 AM
Post #27


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



QUOTE(Trafalgar @ Jul 19 2009, 03:09 AM) *

I'm trying to call public_html/header.php to one of my files located in public_html/forums. When I do this however, it is locating images from public_html/forums/images and not public_html/images. All the images header.php uses are of course in public_html/images. So how do I fix it so that it looks for images in public_html/images instead of public_html/forums/images?


Just a second... what do you mean by "include images"? If in the middle of a php program/web page you suddenly put

include "images/elephant.jpg";

this will include the actual image file into the php program, and php will immediately stop with a fatal error, because it can't interpret the image file as PHP (not surprisingly). Perhaps you mean something else?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jul 19 2009, 07:59 AM
Post #28


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Yes, something else. Trafalgar describes the problem above.

QUOTE(Trafalgar @ Jul 18 2009, 08:09 PM) *

I'm trying to call public_html/header.php to one of my files located in public_html/forums. When I do this however, it is locating images from public_html/forums/images and not public_html/images.

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

2 Pages V < 1 2
Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th April 2024 - 10:00 AM