at the moment a friend and I are working through a PHP tutorial. We are both new to php, but have some general experience in other languages.
We want to include "testseite.php" into our index.php The "testseite.php" is in the folder content/articles
The way the tutorial does it is to use
include("content/articles/".$_GET['include']);
but if we do that there is the following error:
Warning: include(/users/xxx/www/users/xxx/www/myCms/content/articles) [function.include]: failed to open stream: No such file or directory in /users/flateric/www/users/flateric/www/myCms/index.php on line 5
Warning: include() [function.include]: Failed opening 'content/articles/' for inclusion (include_path='.') in /users/xxx/www/users/xxx/www/myCms/index.php on line 5
We thought ourselves that the problem might be, that it doubles the username (i changed it to xxx) and "users" and "www" in the path. Thanks for your help
In PHP, include
means to load the file into the arguments, like loading a library. So, this error means the file /users/flateric/www/users/flateric/www/myCms/index.php does not exist. You should evaluate if the $_GET
value points to a physical file.
It appears that $_GET['include']
is empty (or the include
key is non-existent). This is causing the filename to include to be wrong. You're expecting to include a file named this:
content/articles/testseite.php
but actually getting an include for this:
content/articles/
Clearly, this is incorrect and causes the error. If the $_GET
params don't include the include
value (or it's blank), you should probably consider another approach, such as providing a default value or generating an error to the user.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.