dmccabe Posted June 10, 2008 Share Posted June 10, 2008 I have form in http://myurl.com/custom/forms/myform.php Within this form i want to include a database connection file which is in http://myurl.com/custom/ How can I include this? I have tried: include('./custom/connect.php'); but with no joy. Any ideas? Link to comment https://forums.phpfreaks.com/topic/109557-solved-including-file-from-lower-directory/ Share on other sites More sharing options...
kev wood Posted June 10, 2008 Share Posted June 10, 2008 try it with include('../custom/connect.php'); it should have two full stops before the first slash Link to comment https://forums.phpfreaks.com/topic/109557-solved-including-file-from-lower-directory/#findComment-561939 Share on other sites More sharing options...
jesushax Posted June 10, 2008 Share Posted June 10, 2008 its much easier to include all yoru files from the root, save confusion and errors for files in sub sub foldesr and so on <?php include($_SERVER['DOCUMENT_ROOT'] . '/custom/connect.php'); ?> Link to comment https://forums.phpfreaks.com/topic/109557-solved-including-file-from-lower-directory/#findComment-561940 Share on other sites More sharing options...
thebadbad Posted June 10, 2008 Share Posted June 10, 2008 PHP works like HTML when it comes to paths, right? If so, then just start the path with a slash to start at the root: <?php include('/custom/connect.php'); ?> Link to comment https://forums.phpfreaks.com/topic/109557-solved-including-file-from-lower-directory/#findComment-561943 Share on other sites More sharing options...
dmccabe Posted June 10, 2008 Author Share Posted June 10, 2008 its much easier to include all yoru files from the root, save confusion and errors for files in sub sub foldesr and so on <?php include($_SERVER['DOCUMENT_ROOT'] . '/custom/connect.php'); ?> This is what I was after. Thanks all Link to comment https://forums.phpfreaks.com/topic/109557-solved-including-file-from-lower-directory/#findComment-561945 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.