otuatail Posted October 17, 2007 Share Posted October 17, 2007 This might sound silly but I have a file defaults.inc that has Define (BANNER, "images/top.jpg"); I hve included the file in index.php but can't get the image to work. Any sugestions please http://www.des-otoole.co.uk/cms/index.php Quote Link to comment Share on other sites More sharing options...
cmgmyr Posted October 17, 2007 Share Posted October 17, 2007 can you show us the code that you are using? Quote Link to comment Share on other sites More sharing options...
otuatail Posted October 17, 2007 Author Share Posted October 17, 2007 Cant work oout how to put the code snipets in the quick reply ! *** defaults.inc *** Define (BANNER, "images/top.jpg"); *** index.php *** include ("defaults.inc"); // -------- $banner = BANNER; // -------- <div id="PageTitle"> <img src="<?=$banner?>" alt="Banner"> //defaults.inc </div> Quote Link to comment Share on other sites More sharing options...
cmgmyr Posted October 17, 2007 Share Posted October 17, 2007 do you have short tags enabled on your server? Quote Link to comment Share on other sites More sharing options...
otuatail Posted October 17, 2007 Author Share Posted October 17, 2007 Don't know as I am not the owner of the server. I pay yearly subs and upload content via FTP. I do have a functions.inc with tonns of functions and a config.inc with loads of defines and they work together perfectly. Quote Link to comment Share on other sites More sharing options...
otuatail Posted October 17, 2007 Author Share Posted October 17, 2007 Sorry I did not know what short tags are if you mean using <? in stead of <?php all my pages use <? ?> and <?= without any problem Quote Link to comment Share on other sites More sharing options...
cmgmyr Posted October 17, 2007 Share Posted October 17, 2007 Now just try this on one page: <?php define(BANNER, "images/top.jpg"); ?> <div id="PageTitle"> <img src="<?php echo BANNER ?>" alt="Banner"> </div> Then if that works do: defaults.inc <?php define(BANNER, "images/top.jpg"); ?> and your index page: <?php include "defaults.inc"; ?> <div id="PageTitle"> <img src="<?php echo BANNER ?>" alt="Banner"> </div> and you shouldn't have to do this: $banner = BANNER; it kind of defeats the purpose of your defaults file Quote Link to comment Share on other sites More sharing options...
mattal999 Posted October 17, 2007 Share Posted October 17, 2007 well, looking at the source code of your page: Define (BANNER, "images/top.jpg"); <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Home Page</title> <META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" href="stylesheets/CMS.css" type="text/css"> </head> <body> <div id="PageTitle"> <img src="BANNER" alt="Banner"> //defaults.inc </div> <div id="menu"> <ul id="tabnav"> <li>Home</li> <li><a href="page2.php">Page 2</a></li> </ul> </div> <div ID="w3c"> <IMG src="images/w3c.gif" alt=""><br><IMG src="images/css.gif" alt=""> </div> <div id="PageContent"> <p>This is sample page 3</p> </div> </body> </html> are you using <?php Define (BANNER, "images/top.jpg"); ?> // or just missing out the <?php and ?> Quote Link to comment Share on other sites More sharing options...
otuatail Posted October 17, 2007 Author Share Posted October 17, 2007 Yes this getting somwhere it dosn't matter if i have <?php or just >? and now works without the echo as in <?=BANNER ?> the problem seems to be this. // include ("defaults.inc"); define(BANNER, "images/top.jpg"); it likes it idf the definition is on the page but not drawn from a seperate file. The reason for the seperate file is I will have a lot of pages and keeping the image name in one place would be better. Quote Link to comment Share on other sites More sharing options...
cmgmyr Posted October 17, 2007 Share Posted October 17, 2007 <?=BANNER ?> is only used to echo that variable you still need <?php include "defaults.inc"; ?> at the top of your index page Quote Link to comment Share on other sites More sharing options...
otuatail Posted October 17, 2007 Author Share Posted October 17, 2007 I kbow I need include ("defaults.inc"); at the top of the page. Problem is it won't work with includes If I put define(BANNER, "images/top.jpg"); directly on the same page it works. include ("defaults.inc"); // define(BANNER, "images/top.jpg"); This will not work // include ("defaults.inc"); define(BANNER, "images/top.jpg"); This will work Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted October 17, 2007 Share Posted October 17, 2007 Do you start your include file with "<?php" and end it with "?>"? Ken Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.