Plug-in Posted March 23, 2012 Share Posted March 23, 2012 Hey if you could help me I would really appreciate it, I haven't been coding for a while and I'm getting stuck on quite a basic part of my script, in fact it was the first part. I'm using the include(); function to include a file which will be used to show multiple pages through the $_GET variable, for example if you don't understand what I'm talking about if I was making an "about" page I might do index.php?page=about and it would retrieve the "about" page. Unfortunately I keep getting this error: Warning: include(back_func.php?id=new) [function.include]: failed to open stream: No error in C:\Program Files\EasyPHP-5.3.9\www\link_extension\index.php on line 25 Warning: include() [function.include]: Failed opening 'back_func.php?id=new' for inclusion (include_path='.;C:\php\pear') in C:\Program Files\EasyPHP-5.3.9\www\link_extension\index.php on line 25 Notice: Undefined variable: var in C:\Program Files\EasyPHP-5.3.9\www\link_extension\index.php on line 26 This is the PHP in my index page, notice it consists of one line because I removed the rest for testing: include('back_func.php?id=new'); echo $var; This is my back_func.php page, also simplified for testing: <?php if (isset($_GET['id'])) $var = 'worked'; else $var = 'not'; ?> If you don't understand what I'm asking but feel you could help I'm happy to further explain, I'm expecting it's something basic I've forgotten. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/259565-include-issue/ Share on other sites More sharing options...
onlyican Posted March 23, 2012 Share Posted March 23, 2012 PHP include function basically includes the file data BEFORE process, so passing a parameter will not work try just including back_func.php Quote Link to comment https://forums.phpfreaks.com/topic/259565-include-issue/#findComment-1330515 Share on other sites More sharing options...
Plug-in Posted March 24, 2012 Author Share Posted March 24, 2012 Thanks, I redesigned my idea around what you said. Quote Link to comment https://forums.phpfreaks.com/topic/259565-include-issue/#findComment-1330750 Share on other sites More sharing options...
The Little Guy Posted March 24, 2012 Share Posted March 24, 2012 you should use almost always use require_once unless you need the file to be used more than once on a page. Quote Link to comment https://forums.phpfreaks.com/topic/259565-include-issue/#findComment-1330766 Share on other sites More sharing options...
Plug-in Posted March 25, 2012 Author Share Posted March 25, 2012 Thanks, I usually do but it was just drafting the code to make sure I could get it to work, and I couldn't but fortunately I've fixed it up Quote Link to comment https://forums.phpfreaks.com/topic/259565-include-issue/#findComment-1330894 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.