July 10, 201115 yr Hey, my php include won't work. I haven't uploaded it to a server yet, so I'll have to paste all the code here. index.php <html> <head> <title>site title here</title> <LINK rel=StyleSheet href="css.css" type="text/css" media=screen> </head> <body> <div id="container" align="center"> <div id="header"> <a href="index.php"><img src="images/logo.png"></a> </div> <div id="menu" align="right"> </div> </div> </body> <html> menu.php <a href="index.php">Home</a> <a href="index.php">Services</a> <a href="index.php">Portfolio</a> <a href="index.php">Contact</a> Am I doing something wrong? Regards
July 10, 201115 yr actually using an include might help somewhat <div id="menu" align="right"> <?php include 'menu.php'; ?> </div>
July 10, 201115 yr Author Sorry, I deleted that out. Even when I use that code where I want it, it doesn't work?
July 10, 201115 yr then its a path problem, the file is not in the same place as the file your include menu into for future... don't delete code unless its passwords, makes it harder to help
July 11, 201115 yr <?php include("name.php"); ?> This is the basic php include code and just as an addition if the file is located 1 file under you do ../ is it 2 files more under then it's ../../ else file up "directoryname/name.php" I hope this will help you.
July 12, 201115 yr <?php include("name.php"); ?> This is the basic php include code and just as an addition if the file is located 1 file under you do ../ is it 2 files more under then it's ../../ else file up "directoryname/name.php" I hope this will help you. theres sorta a better way to do this i'd do something like, defining a site path define('SITE_PATH',dirname(__FILE__) . '/'); then use it like this require SITE_PATH . 'common.php'; however if the dir is 1 level below you will need to do require dirname(SITE_PATH) . '/common.php';
Create an account or sign in to comment