gwh Posted December 23, 2009 Share Posted December 23, 2009 Hi everyone, I have a separate php file that's located in a specific directory and it includes another php file, ie. include '../../catalogue.php'; The abovementioned catalogue.php file has a whole heap of links to other javascript files whose paths work in relation to the catalogue.php file, eg. <script language="javascript" type="text/javascript" src="../../ScriptLibrary/jquery-latest.pack.js"></script> <script language="javascript" type="text/javascript" src="../../dmx/dmx.core.js" id="dmxCoreJS"></script> <script language="javascript" type="text/javascript" src="../../dmx/widgets/Lightbox/dmx.lightbox.js"></script> ...however, when the catalogue.php file is included from the other controller file (see the code below), the paths no longer work. Does this mean I have to change the above paths so that they are correct in relation to the controller file below? Hope that makes sense and appreciate any help. <?php $link = mysqli_connect('localhost', 'root', 'root'); if (!$link) { $output = 'Unable to connect to the database server.'; include 'output.html.php'; exit(); } if (!mysqli_set_charset($link, 'utf8')) { $output = 'Unable to set database connection encoding.'; include 'output.html.php'; exit(); } if (!mysqli_select_db($link, 'catalogue')) { $output = 'Unable to locate the catalogue database.'; include 'output.html.php'; exit(); } $output = 'Database connection established.'; include 'output.html.php'; $result = mysqli_query($link, 'SELECT shirtDescLadies, shirtDescMen FROM shirts'); if (!$result) { $error = 'Error fetching description: ' . mysqli_error($link); include 'error.html.php'; exit(); } while ($row = mysqli_fetch_array($result)) { $descriptions[] = array('shirtDescLadies' => $row['shirtDescLadies'], 'shirtDescMen' => $row['shirtDescMen']); } include '../../catalogue.php'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/186133-paths-no-longer-work-once-file-is-included/ Share on other sites More sharing options...
bowett Posted December 23, 2009 Share Posted December 23, 2009 Yes, I think the paths have to be relative to the controller file, not the included file. Quote Link to comment https://forums.phpfreaks.com/topic/186133-paths-no-longer-work-once-file-is-included/#findComment-982981 Share on other sites More sharing options...
gwh Posted December 23, 2009 Author Share Posted December 23, 2009 Thanks Quote Link to comment https://forums.phpfreaks.com/topic/186133-paths-no-longer-work-once-file-is-included/#findComment-982987 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.