Reputation: 3809
Trying to include file in .php file:
<?php
$lesson = $_GET["lesson"];
include_once($lesson + "_title.php");
?>
But for some reason I keep getting this error:
Warning: include_once(0): failed to open stream: No such file or directory in C:\xampp\htdocs\Periodic Tutor\layout.php on line 10
Warning: include_once(): Failed opening '0' for inclusion (include_path='.;\xampp\php\PEAR') in C:\xampp\htdocs\Periodic Tutor\layout.php on line 10
It keeps showing that the file doesn't exist, yet it does. I have done an echo statement to check the arguments being passed to the include function and the string is correct.
I am using XAMPP as my testing server and Dreamweaver, but PHP url variables and include/require statements have never been a problem before.
Any suggestions? Thanks!
Upvotes: 0
Views: 679
Reputation:
In this line:
include_once($lesson + "_title.php");
You're arithmetically adding the two terms, which gives a result of zero.
Do this:
include_once($lesson . "_title.php");
Upvotes: 1
Reputation: 1877
When concatenating a string, you use "." not "+". include_once($lesson."_title.php");
Keep in mind that including things that way is a bit dangerous as people could use absolute paths in $_GET["lesson"] to include things that could be private.
Upvotes: 2