Petsmacker Posted February 3, 2008 Share Posted February 3, 2008 Very simple question with what I hope will be a simple answer. Here's what I want to do simplified: <?php $x_id=4; include (mypage.php?var=$x_id); ?> Is this possible? I need the x_id variable to be dynamic depending on circumstances. Cheers! Quote Link to comment https://forums.phpfreaks.com/topic/89224-variable-in-include-url/ Share on other sites More sharing options...
monkeytooth Posted February 3, 2008 Share Posted February 3, 2008 when you phase them through your script... im assuming your using a url to phase them or a form element.. Your Code: <?php $x_id=4; include (mypage.php?var=$x_id); ?> Try (With Form Elements): <?php $x_id=$_POST['form_element_name']; include (mypage.php?var=$x_id); ?> With URL's <?php $x_id=$_GET['variable_name']; include (mypage.php?var=$x_id); ?> Quote Link to comment https://forums.phpfreaks.com/topic/89224-variable-in-include-url/#findComment-456860 Share on other sites More sharing options...
Petsmacker Posted February 3, 2008 Author Share Posted February 3, 2008 Sorry, I should elaborate. The problem is putting a variable inside an include function, not generating the variable itself. Everytime I try, the include file doesn't show. Quote Link to comment https://forums.phpfreaks.com/topic/89224-variable-in-include-url/#findComment-456874 Share on other sites More sharing options...
Aureole Posted February 3, 2008 Share Posted February 3, 2008 I'm guessing <?php $id = 4; include( 'file.php?' . $id ); ?> ...should work. Quote Link to comment https://forums.phpfreaks.com/topic/89224-variable-in-include-url/#findComment-456881 Share on other sites More sharing options...
PFMaBiSmAd Posted February 3, 2008 Share Posted February 3, 2008 GET parameters on the end of the URL in a local/file system include() don't work. No guessing is needed, its in the php manual. Quote Link to comment https://forums.phpfreaks.com/topic/89224-variable-in-include-url/#findComment-456885 Share on other sites More sharing options...
Aureole Posted February 3, 2008 Share Posted February 3, 2008 Well I haven't read the entire PHP Manual, so I wouldn't know... though now I do. Quote Link to comment https://forums.phpfreaks.com/topic/89224-variable-in-include-url/#findComment-456887 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.