timecatcher Posted August 1, 2008 Share Posted August 1, 2008 Hey everyone im trying to create a new page and to do so I want to require the connect to database file so that everything can connect to it. However when I run it I get this error: Warning: require(includes/connect.inc.php) [function.require]: failed to open stream: No such file or directory in /home/timecat/public_html/games/holgame.php on line 2 Warning: require(includes/connect.inc.php) [function.require]: failed to open stream: No such file or directory in /home/timecat/public_html/games/holgame.php on line 2 Fatal error: require() [function.require]: Failed opening required 'includes/connect.inc.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/timecat/public_html/games/holgame.php on line 2 Which I don't understand considering I've included that same file before in all my other files. Help needed thanks. Timecatcher. Quote Link to comment https://forums.phpfreaks.com/topic/117724-solved-require-error/ Share on other sites More sharing options...
DeanWhitehouse Posted August 1, 2008 Share Posted August 1, 2008 try using an aboslute link , and check the file names and the folder names Quote Link to comment https://forums.phpfreaks.com/topic/117724-solved-require-error/#findComment-605496 Share on other sites More sharing options...
timecatcher Posted August 1, 2008 Author Share Posted August 1, 2008 Whats an absolute link sorry? Timecatcher. Quote Link to comment https://forums.phpfreaks.com/topic/117724-solved-require-error/#findComment-605498 Share on other sites More sharing options...
elflacodepr Posted August 1, 2008 Share Posted August 1, 2008 Warning: require(includes/connect.inc.php) [function.require]: failed to open stream: No such file or directory in /home/timecat/public_html/games/holgame.php on line 2 Warning: require(includes/connect.inc.php) [function.require]: failed to open stream: No such file or directory in /home/timecat/public_html/games/holgame.php on line 2 I recommend to use the .php extension as some servers don't see with good eyes the .inc one, it will do exactly the same , it will look like: connect.php I personally always use "include" instead of "require" and always works fine to me this is an example include "includes/connect.php"; Quote Link to comment https://forums.phpfreaks.com/topic/117724-solved-require-error/#findComment-605499 Share on other sites More sharing options...
DeanWhitehouse Posted August 1, 2008 Share Posted August 1, 2008 an absoulte link is http://link.com/link.php instead of just using /link.php Quote Link to comment https://forums.phpfreaks.com/topic/117724-solved-require-error/#findComment-605500 Share on other sites More sharing options...
timecatcher Posted August 1, 2008 Author Share Posted August 1, 2008 Thanks but require works for all my other pages and also .inc works fine with my server. Timecatcher. Quote Link to comment https://forums.phpfreaks.com/topic/117724-solved-require-error/#findComment-605502 Share on other sites More sharing options...
DeanWhitehouse Posted August 1, 2008 Share Posted August 1, 2008 is this file in the same folder as the other files that work? Quote Link to comment https://forums.phpfreaks.com/topic/117724-solved-require-error/#findComment-605506 Share on other sites More sharing options...
PFMaBiSmAd Posted August 1, 2008 Share Posted August 1, 2008 The error message is not lying. It is telling you what php found when it tried to execute your code - require(includes/connect.inc.php) No such file or directory. Either the file or directory does not exist relative to the main script that is being executed. Now to the other posts made - You would want to use an absolute file system path, not a link/url, because an include/require using a URL will not actually include the code into the current script. The file name being used, according to the error message, is connect.inc.php, not connect.inc and the actual file name does not matter except if you use a file name not ending in .php, someone can browse to your file and see the php code in it, so if you are using .inc, don't put anything like database usenames or passwords in your file. Quote Link to comment https://forums.phpfreaks.com/topic/117724-solved-require-error/#findComment-605508 Share on other sites More sharing options...
timecatcher Posted August 1, 2008 Author Share Posted August 1, 2008 Alright I fixed it, it was require("../includes/connect.inc.php") this meant that it wasn't searching for includes in the games file. Thanks for your help guys. Quote Link to comment https://forums.phpfreaks.com/topic/117724-solved-require-error/#findComment-605509 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.