aeroswat Posted December 7, 2009 Share Posted December 7, 2009 Is include not able to use GET variables in the location name? This doesn't seem to work... include 'order.php?sn=1'; Quote Link to comment https://forums.phpfreaks.com/topic/184305-include/ Share on other sites More sharing options...
premiso Posted December 7, 2009 Share Posted December 7, 2009 No, because you would just define the variable instead. $_GET['sn'] = 1; // or $sn = 1; however it is coded include 'order.php'; Would work, reason being. You are including the script and not executing it. If you want it to execute you can use file_get_contents to execute it then echo the output, but you would have to use the full URL. Quote Link to comment https://forums.phpfreaks.com/topic/184305-include/#findComment-973008 Share on other sites More sharing options...
aeroswat Posted December 7, 2009 Author Share Posted December 7, 2009 Would header work? Edit: Nevermind I see what you are saying... it works this way. Although strangely enough using that same include is not still retrieving other variables... it's picking and choosing what variables it wants to keep for some reason. Quote Link to comment https://forums.phpfreaks.com/topic/184305-include/#findComment-973010 Share on other sites More sharing options...
premiso Posted December 7, 2009 Share Posted December 7, 2009 Would header work? If you want to redirect to the page, sure. Quote Link to comment https://forums.phpfreaks.com/topic/184305-include/#findComment-973013 Share on other sites More sharing options...
mrMarcus Posted December 7, 2009 Share Posted December 7, 2009 no. include() is simply, well, including the code from the respective file. the statement does not execute/parse/etc., the code as a browser would if using the $_GET superglobal in the URL or something along those lines. it's used just to include a file so that the respective code/script is made available to the parent script/file. you could look into several functions that might (or might not work) in this case to accomplish such a task: curl, file_get_contents, fopen, just to name a few. EDIT: or do as premiso's first post there suggested. Quote Link to comment https://forums.phpfreaks.com/topic/184305-include/#findComment-973014 Share on other sites More sharing options...
aeroswat Posted December 7, 2009 Author Share Posted December 7, 2009 Oddly enough it is not reading 90% of the variables... It is correctly still able to access that get variable but it is not able to read regular variables... any idea for why this is? The code that declares the variables is included next to the include of the same code that tries to read it... Quote Link to comment https://forums.phpfreaks.com/topic/184305-include/#findComment-973017 Share on other sites More sharing options...
mrMarcus Posted December 7, 2009 Share Posted December 7, 2009 there is no reason those variables can't be accessed from one include file to the other. once a file is included, it is as if that code is embedded directly on the page. show code on how you are declaring variables and how they are being used in the included file(s). Quote Link to comment https://forums.phpfreaks.com/topic/184305-include/#findComment-973028 Share on other sites More sharing options...
aeroswat Posted December 7, 2009 Author Share Posted December 7, 2009 Ok I got it to work... Now I have another issue... The display on the divider at the bottom is not working correctly. If the variable is set to 1 then this divider should show... if not it should be hidden. The div id is hidBook Took this out Quote Link to comment https://forums.phpfreaks.com/topic/184305-include/#findComment-973039 Share on other sites More sharing options...
premiso Posted December 7, 2009 Share Posted December 7, 2009 "<div id='hidBook' style='display:" . ($ordBook=='1' ? 'block' : 'none') . ";'>" . You have to concatenate it since it is an operation that is taking place. Quote Link to comment https://forums.phpfreaks.com/topic/184305-include/#findComment-973043 Share on other sites More sharing options...
aeroswat Posted December 7, 2009 Author Share Posted December 7, 2009 Wow... nevermind i'm a dummy. I forgot the concat operator for echo >< EDIT: Ya lol sorry Quote Link to comment https://forums.phpfreaks.com/topic/184305-include/#findComment-973046 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.