postbil.com Posted January 11, 2011 Share Posted January 11, 2011 Hello Phofreaks. I had a little problem With the include() function. 1.Example – works fine $validate = 'C:\xampp\htdocs\includes\userData.inc.php'; include $validate; 2.exampel – Get an error $validate = '../includes/userData.inc.php'; include $validate; I do not understand what the different is, but every time I get the following error. include(../includes/userData.inc.php) [function.include]: failed to open stream: No such file or directory - Postbil.com Quote Link to comment https://forums.phpfreaks.com/topic/224123-i-had-a-little-problem-with-the-include-function/ Share on other sites More sharing options...
shlumph Posted January 11, 2011 Share Posted January 11, 2011 You're using an absolute path in the first example, but a relative path in the second example. And the relative path isn't correct... Quote Link to comment https://forums.phpfreaks.com/topic/224123-i-had-a-little-problem-with-the-include-function/#findComment-1158086 Share on other sites More sharing options...
taquitosensei Posted January 11, 2011 Share Posted January 11, 2011 It looks like you're running your file in htdocs and need to drop the "../" from the relative path. Quote Link to comment https://forums.phpfreaks.com/topic/224123-i-had-a-little-problem-with-the-include-function/#findComment-1158087 Share on other sites More sharing options...
postbil.com Posted January 12, 2011 Author Share Posted January 12, 2011 okay.. I hat try to change the code: $validate = realpath('includes/userData.inc.php'); include $validate; But I Still get an error. include() [function.include]: Filename cannot be empty in C:\xampp\htdocs\modules\updateUser.inc.php Quote Link to comment https://forums.phpfreaks.com/topic/224123-i-had-a-little-problem-with-the-include-function/#findComment-1158477 Share on other sites More sharing options...
shlumph Posted January 13, 2011 Share Posted January 13, 2011 http://www.php.net/realpath realpath() returns FALSE on failure, e.g. if the file does not exist. Quote Link to comment https://forums.phpfreaks.com/topic/224123-i-had-a-little-problem-with-the-include-function/#findComment-1158651 Share on other sites More sharing options...
postbil.com Posted January 15, 2011 Author Share Posted January 15, 2011 Do you have a way to work behind this error? Quote Link to comment https://forums.phpfreaks.com/topic/224123-i-had-a-little-problem-with-the-include-function/#findComment-1159871 Share on other sites More sharing options...
phpfreak Posted January 15, 2011 Share Posted January 15, 2011 try the DOCUMENT_ROOT: <? include($_SERVER['DOCUMENT_ROOT'].'/includes/userData.inc.php'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/224123-i-had-a-little-problem-with-the-include-function/#findComment-1159873 Share on other sites More sharing options...
postbil.com Posted January 15, 2011 Author Share Posted January 15, 2011 Yes yes, that great.. It works perfect thanks a lot Quote Link to comment https://forums.phpfreaks.com/topic/224123-i-had-a-little-problem-with-the-include-function/#findComment-1159909 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.