Jump to content

Include code works on one page but not another


eGate-Network

Recommended Posts

Hi all,
I am a bit of a noob when it comes to website building and php etc so please have patients with me I am learnig as I go.

I have come across this problem before and cannot remember what I did to fix it but any way it is presenting its self to me again.

I have this page: http://minecraftconsolecrafting.comxa.com/index.php with an include file loading random images, however the same code on these pages:
http://minecraftconsolecrafting.comxa.com/sections/build-navi.php
http://minecraftconsolecrafting.comxa.com/sections/springhill-kingdom-01.php
are not working.

I have other websites that this method of coding is working fine on for example here is another of my websites:
http://divinegardensandlandscapes.com/index.php here the include code for random image loader is working fine on all pages it appears on so what is happening when this fail takes place?

Any help and or advice would be hugely appreciated, Thanks in advance.

Please remeber I am a noob when answering. Thanks

Edited by eGate-Network
Link to comment
Share on other sites

If you don't mind, I'm going to not look at those pages and instead make a guess.

 

The URLs to those images. Are you using relative paths? Paths that don't start with a slash like "topic/289806-include-code-works-on-one-page-but-not-another/". They're relative to the current "directory" of the page. With the second and third URLs the browser will go looking for "/sections/path/to/image" when it should have gone looking for "/path/to/image".

 

Put a slash at the beginning of the URLs.

Link to comment
Share on other sites

Sorry? I am a little offended. Why wouldnt you want to look at the pages and just make a guess?

Its not like its a page full of offensive stuff, its just pictures of minecraft, geez, and because you wont look at it that means you have got your guess wrong,

Yes i have tried that thanks any way.

Link to comment
Share on other sites

If you don't mind, I'm going to not look at those pages and instead make a guess.

 

The URLs to those images. Are you using relative paths? Paths that don't start with a slash like "topic/289806-include-code-works-on-one-page-but-not-another/". They're relative to the current "directory" of the page. With the second and third URLs the browser will go looking for "/sections/path/to/image" when it should have gone looking for "/path/to/image".

 

Put a slash at the beginning of the URLs.

Useless response. Any one here worth listening to?

Link to comment
Share on other sites

It's fine to be offended... if I'm wrong.

function banner() { } ; b = new banner() ; n = 0
b[n++]= "<A target='_blank' HREF='http://flowernursery.co.uk'><IMG SRC='random-ads/flower-nursery-banner-01.png' border='0' title='Flower Nursery' >"
b[n++]= "<A target='_blank' HREF='http://greatviewlandscapes.com'><IMG SRC='random-ads/greatviewlandscapes-banner.png' border='0' title='Great View Landscapes' >"
b[n++]= "<A target='_blank' HREF='http://egatemarket.com'><IMG SRC='random-ads/egm-ad-728x90-banner.png' border='0' title='eGate Market' >"
b[n++]= "<A target='_blank' HREF='http://divinegardensandlandscapes.com'><IMG SRC='random-ads/divine-banner-01.png' border='0' title='Divine Gardens & Landscapes' >"
b[n++]= "<A target='_blank' HREF='http://minecraftconsolecrafting.comxa.com'><IMG SRC='random-ads/mcc-banner-01.png' border='0' title='MCC Crafting Minecraft PS3 Edition' >"
<img border="0" src="random-ads/egm-ad-160x600-video-games.png" alt="Buy & Sell New & Used Video Games For FREE!" title="Buy & Sell New & Used Video Games For FREE!" vspace="5" width="160" height="600">
What's this? I was right?

 

Slashes. Add them.

function banner() { } ; b = new banner() ; n = 0
b[n++]= "<A target='_blank' HREF='http://flowernursery.co.uk'><IMG SRC='/random-ads/flower-nursery-banner-01.png' border='0' title='Flower Nursery' >"
b[n++]= "<A target='_blank' HREF='http://greatviewlandscapes.com'><IMG SRC='/random-ads/greatviewlandscapes-banner.png' border='0' title='Great View Landscapes' >"
b[n++]= "<A target='_blank' HREF='http://egatemarket.com'><IMG SRC='/random-ads/egm-ad-728x90-banner.png' border='0' title='eGate Market' >"
b[n++]= "<A target='_blank' HREF='http://divinegardensandlandscapes.com'><IMG SRC='/random-ads/divine-banner-01.png' border='0' title='Divine Gardens & Landscapes' >"
b[n++]= "<A target='_blank' HREF='http://minecraftconsolecrafting.comxa.com'><IMG SRC='/random-ads/mcc-banner-01.png' border='0' title='MCC Crafting Minecraft PS3 Edition' >"
<img border="0" src="/random-ads/egm-ad-160x600-video-games.png" alt="Buy & Sell New & Used Video Games For FREE!" title="Buy & Sell New & Used Video Games For FREE!" vspace="5" width="160" height="600">

[edit] Oh, and spoiler: I lied. I did check first. But somehow I don't think that's the point here. So don't go getting all offended that someone didn't spend a lot of time on your problem and then ignore what they say, because if they turn out to be right, they're not going to be the one looking bad for it.

Edited by requinix
Link to comment
Share on other sites

It's fine to be offended... if I'm wrong.

function banner() { } ; b = new banner() ; n = 0
b[n++]= "<A target='_blank' HREF='http://flowernursery.co.uk'><IMG SRC='random-ads/flower-nursery-banner-01.png' border='0' title='Flower Nursery' >"
b[n++]= "<A target='_blank' HREF='http://greatviewlandscapes.com'><IMG SRC='random-ads/greatviewlandscapes-banner.png' border='0' title='Great View Landscapes' >"
b[n++]= "<A target='_blank' HREF='http://egatemarket.com'><IMG SRC='random-ads/egm-ad-728x90-banner.png' border='0' title='eGate Market' >"
b[n++]= "<A target='_blank' HREF='http://divinegardensandlandscapes.com'><IMG SRC='random-ads/divine-banner-01.png' border='0' title='Divine Gardens & Landscapes' >"
b[n++]= "<A target='_blank' HREF='http://minecraftconsolecrafting.comxa.com'><IMG SRC='random-ads/mcc-banner-01.png' border='0' title='MCC Crafting Minecraft PS3 Edition' >"
<img border="0" src="random-ads/egm-ad-160x600-video-games.png" alt="Buy & Sell New & Used Video Games For FREE!" title="Buy & Sell New & Used Video Games For FREE!" vspace="5" width="160" height="600">
What's this? I was right?

 

Slashes. Add them.

function banner() { } ; b = new banner() ; n = 0
b[n++]= "<A target='_blank' HREF='http://flowernursery.co.uk'><IMG SRC='/random-ads/flower-nursery-banner-01.png' border='0' title='Flower Nursery' >"
b[n++]= "<A target='_blank' HREF='http://greatviewlandscapes.com'><IMG SRC='/random-ads/greatviewlandscapes-banner.png' border='0' title='Great View Landscapes' >"
b[n++]= "<A target='_blank' HREF='http://egatemarket.com'><IMG SRC='/random-ads/egm-ad-728x90-banner.png' border='0' title='eGate Market' >"
b[n++]= "<A target='_blank' HREF='http://divinegardensandlandscapes.com'><IMG SRC='/random-ads/divine-banner-01.png' border='0' title='Divine Gardens & Landscapes' >"
b[n++]= "<A target='_blank' HREF='http://minecraftconsolecrafting.comxa.com'><IMG SRC='/random-ads/mcc-banner-01.png' border='0' title='MCC Crafting Minecraft PS3 Edition' >"
<img border="0" src="/random-ads/egm-ad-160x600-video-games.png" alt="Buy & Sell New & Used Video Games For FREE!" title="Buy & Sell New & Used Video Games For FREE!" vspace="5" width="160" height="600">
[edit] Oh, and spoiler: I lied. I did check first. But somehow I don't think that's the point here. So don't go getting all offended that someone didn't spend a lot of time on your problem and then ignore what they say, because if they turn out to be right, they're not going to be the one looking bad for it.

 

What?

 

Sorry I am not offended someone may not want to spend long on my problem, I am offended you come to my post on a forum where you obviously try to help people or get help and start with "If you don't mind, I'm going to not look at those pages and instead make a guess."

 

Anyway your still wrong as your just talking about a random src code for a random image not used in this include, nothing to do with my question? I am a complete noob at all this and yet am baffled that this is the best respons on this forum.

 

If anyone here does have 5 mins to help and wants to, I am looking for assistance with the include file code on the above mentioned pages. Not anything else like random src codes etc.

 

Thanks a million.

 

UPDATE: Just to be sure the slashes have been implemented in the src codes and no difference.

Edited by eGate-Network
Link to comment
Share on other sites

You do need somthing similar to the / like mensioned above, but with a slight difference cause you're dealing with server side rather than client side for this particular issue.  Put this piece of code towards the top of your main include so that it can be used on everypage.

define("ROOT", $_SERVER['DOCUMENT_ROOT'].'/');

Then for your includes you woudl do something like this

include(ROOT.'yourpage.php');

That will tell php to find the included page starting from the domain root rather than the root of "sections"

Link to comment
Share on other sites

Another thing, your html is absolutely horrible.  You need to get away from using tables for layout, it hasn't been good to do that for over 10 years now.  Use divs and css.  Also you have dual <title> tags and they aren't even inside <html> or <head> tags.  You have dual <head> tags too and lots of html before you open the <body> which is where ALL your html markup should be inside.  So you really need to fix all that before moving forward or you're asking more problems when you try to put things where you want and wonder why they aren't working n the browser.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.