php include from a different directory? |
php include from a different directory? |
Trafalgar |
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 |
pandy |
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.
|
Trafalgar |
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?
|
pandy |
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 |
Trafalgar |
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.
|
pandy |
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!
|
Brian Chandler |
Jul 19 2009, 03:06 AM
Post
#27
|
Jocular coder Group: Members Posts: 2,460 Joined: 31-August 06 Member No.: 43 |
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? |
pandy |
Jul 19 2009, 07:59 AM
Post
#28
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,730 Joined: 9-August 06 Member No.: 6 |
|
Lo-Fi Version | Time is now: 19th April 2024 - 10:00 AM |