churdaddy Posted February 11, 2007 Share Posted February 11, 2007 Could someone help this newb? I am trying to setup a file system that pulls from teh querystring and then includes a page of links in my existing webpage. <?PHP $PartNum = $_GET['Part']; $PartPath = "../Parts/" .$PartNum. "/index.php"; include($PartPath); ?> Ive changed this a dozen times in different ways. The way it is now at least it doesn't keep the whole page from showing, but nothing in my Index php I'm trying to include shows up in the page. If I simply do <?PHP include("../Parts/113507/index.php"); ?> It works perfectly, but I want this data to change with the Querystring. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
steelmanronald06 Posted February 11, 2007 Share Posted February 11, 2007 <?php $root = ".."; $PartNum = $_GET['Part']; include ("{$path}/Parts/{$PartNum}/index.php"); ?> Try that. Quote Link to comment Share on other sites More sharing options...
churdaddy Posted February 11, 2007 Author Share Posted February 11, 2007 Same result. The PHP does nothing. The page this is inside of comes up but nothing from the include shows. So both pieces of code work exactly the same. Quote Link to comment Share on other sites More sharing options...
steelmanronald06 Posted February 11, 2007 Share Posted February 11, 2007 do an echo on $PartNum and see if anything is in it. Quote Link to comment Share on other sites More sharing options...
heckenschutze Posted February 11, 2007 Share Posted February 11, 2007 <?php $root = ".."; $PartNum = $_GET['Part']; include ("{$path}/Parts/{$PartNum}/index.php"); ?> Try that. I assume you have heard of URL injection...? Quote Link to comment Share on other sites More sharing options...
steelmanronald06 Posted February 11, 2007 Share Posted February 11, 2007 yes i have. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted February 11, 2007 Share Posted February 11, 2007 Try this... <?php $PartNum=$_GET['Part']; $PartPath="../Parts/" .$PartNum. "/index.php"; $codeline='include('.$PartPath.');'; eval($codeline); ?> Quote Link to comment Share on other sites More sharing options...
churdaddy Posted February 11, 2007 Author Share Posted February 11, 2007 Tried both echo $PartNum; Does return the part number exactly correct. <?php $PartNum=$_GET['Part']; $PartPath="../Parts/" .$PartNum. "/index.php"; $codeline='include('.$PartPath.');'; eval($codeline); ?> Acted exactly as the old code. The index.php was not displayed in the page. Quote Link to comment Share on other sites More sharing options...
steelmanronald06 Posted February 12, 2007 Share Posted February 12, 2007 will you paste the entire page of code here? perhaps something else is wrong on that page Quote Link to comment Share on other sites More sharing options...
churdaddy Posted February 12, 2007 Author Share Posted February 12, 2007 Alright this is huge though. The Embed statement works perfectly. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr"> <!-- #BeginTemplate "../master.dwt" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- #BeginEditable "doctitle" --> <title>Links</title> <!-- #EndEditable --> <link rel="stylesheet" title="CSS" type="text/css" href="../styles/style2.css" media="screen" /> <style type="text/css"> .style1 { text-align: center; } .style2 { margin-left: 41; } .style3 { text-decoration: underline; } </style> </head> <body> <!-- Begin Container --> <div id="container" style="width: 959px; height: 794px"> <!-- Begin Masthead --> <div id="masthead"> <h1 class="style1"> <img alt="Electritek" src="../images/LogoETI.gif" width="251" height="40" /><img alt="AVT" src="../images/LogoAVT.gif" width="125" height="40" /></h1> <h3><a href="http://www.electritek.com">www.electritek.com</a></h3> </div> <!-- End Masthead --> <!-- Begin Navigation --> <div id="navigation"> <ul> <li><a href="../default.htm">Home</a></li> <li><a href="../about_me/about_me.htm">Links</a></li> <li><a href="../photo_gallery/photo_gallery.htm">Photo Gallery</a></li> <li><a href="PartInfo.php?Doc=ETI_Line_Card.pdf">Documents</a></li> <li><a href="../contact/contact.htm">Contact</a></li> </ul> </div> <!-- End Navigation --> <!-- Begin content_container --> <div id="content_container"> <!-- Begin Left Column --> <div id="column_left" style="width: 530px"> <!-- #BeginEditable "content" --> <embed width="530" src="../Parts/<?PHP echo $_GET['Part']?>/<?PHP echo $_GET['Doc']?>" style="height: 606px"> <!-- #EndEditable --></div> <!-- End Left Column --> <!-- Begin Right Column --> <div id="column_right" class="style2" style="width: 212px; height: 597px"> <!-- #BeginEditable "sidebar" --> <?php $root = ".."; $PartNum = $_GET['Part']; include ("{$path}/Parts/{$PartNum}/index.php"); echo $PartNum; ?> Yadda Yadda Yadda <!-- #EndEditable --></div> <!-- End Right Column --> <!-- Begin Footer --> <div id="footer"> <div id="copyright"> <p>Copyright © 0000. All Rights Reserved.</p> </div> <p><a href="../default.htm">Home</a> | <span class="style3"><strong> <a href="../about_me/about_me.htm">Links </a></strong></span>| <a href="../photo_gallery/photo_gallery.htm">Photo Gallery</a> |<a href="PartInfo.php?Doc=ETI_Line_Card.pdf"">Documents</a>| <a href="../contact/contact.htm"> Contact</a></p> </div> <!-- End Footer --></div> <!-- End content_container --></div> <!-- End Container --> </body> <!-- #EndTemplate --> </html> The Part number and Yadda Yadda Yadda both show fine. The index.php is here. <h1>Documents</h1> <BR /> <a href="PartInfo.php?Part=<?PHP echo $_GET['Part']?>&Doc=AVT_ETI_Line_Card.pdf">Doc One</a> <BR /> <h1> Sub Assemblys - Parts </h1> <BR /> <a href="PartInfo.php?Part=<?PHP echo $_GET['Part']?>&Doc=Start.pdf">Start</a> Quote Link to comment Share on other sites More sharing options...
heckenschutze Posted February 12, 2007 Share Posted February 12, 2007 I don't see $path defined anywhere... Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted February 12, 2007 Share Posted February 12, 2007 try and change $path to $root Quote Link to comment Share on other sites More sharing options...
churdaddy Posted February 12, 2007 Author Share Posted February 12, 2007 Yeah My bad I should have seen that. On the other hand it didnt work. Code is now $root = ".."; $PartNum = $_GET['Part']; include ("{$root}/Parts/{$PartNum}/index.php"); echo $PartNum; ?> Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 12, 2007 Share Posted February 12, 2007 You still have $path and $root, they're not the same. Quote Link to comment Share on other sites More sharing options...
churdaddy Posted February 12, 2007 Author Share Posted February 12, 2007 Sorry cut and pasted the wrong script fixed it. on a different note does work as this either $PartNum = $_GET['Part']; include ("../Parts/{$PartNum}/index.php"); echo $PartNum; ?> Quote Link to comment Share on other sites More sharing options...
churdaddy Posted February 12, 2007 Author Share Posted February 12, 2007 I reworked this quite a bit for debugging. <?php $PartNum=$_GET['Part']; $PartPath="../Parts/" .$PartNum. "/index.php"; $codeline='include($PartPath);'; eval($codeline); include($PartPath); echo $codeline; echo '<br>'; echo $PartPath; echo '<br>'; echo $PartNum; echo '<br>'; ?> This returns include($PartPath); ../Parts/AVT-900-112/index.php AVT-900-112 On the page. I think this proves that all the variables are working correctly. So two questions: Is it even possible to have a variable in the include line? If so what is going wrong? Thanks again everyone for working on this. Quote Link to comment Share on other sites More sharing options...
Balmung-San Posted February 12, 2007 Share Posted February 12, 2007 Call me crazy, but does the file exist? If it doesn't exist include() doesn't throw an error. Try using require() instead of include and see if it throws an error. Also, does the included page echo anything? If it doesn't echo anything just including it isn't going to do anything. Quote Link to comment Share on other sites More sharing options...
churdaddy Posted February 12, 2007 Author Share Posted February 12, 2007 I thought of that and spent time with it. if I do this it works perfect. include('../Parts/AVT-900-112/index.php') Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 12, 2007 Share Posted February 12, 2007 How do you know it's not working with the variable? Use require. Quote Link to comment Share on other sites More sharing options...
churdaddy Posted February 12, 2007 Author Share Posted February 12, 2007 Alright the file exist-- More internal Information http://192.168.1.4/PartInfo/PartInfo.php?Part=AVT-900-112&Doc=Start.pdf Is what I use to get to the whole page http://192.168.1.4/Parts/AVT-900-112/index.php directly in the address of IE Brings up the navigation bar I'm trying to create as a page and it shows its links fine. the wierd thing is that this code stops processing require('../Parts/AVT-900-112/index.php'); I was wrong in my previous post today I have been unable to make this work either . include('../Parts/AVT-900-112/index.php'); I guess one more question Parts is a virtual directory in IIS. do I need with PHP to make the include point to the actual folder on the system or is just pointing to the folder through the IIS path good enough? Quote Link to comment Share on other sites More sharing options...
Balmung-San Posted February 12, 2007 Share Posted February 12, 2007 Instead of using a relative path, try using an absolute path: include('http://192.168.1.4/Parts/'.$PartNum.'/index.php'); The fact that it dies after your require() means that it cannot find and/or open the file. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted February 12, 2007 Share Posted February 12, 2007 If you are not getting an error, Make sure the folder exists, and the file (index.php) actually contains something. And just make sure you know what these mean: / - Root ../ - Back One folder Quote Link to comment Share on other sites More sharing options...
churdaddy Posted February 12, 2007 Author Share Posted February 12, 2007 I got it had to use <?php $PartNum=$_GET['Part']; $PartPath='c:/etek/Engineering/Parts/' .$PartNum. '/index.php'; include($PartPath); ?> Thanks for all the help Quote Link to comment Share on other sites More sharing options...
steelmanronald06 Posted February 13, 2007 Share Posted February 13, 2007 Just for reference, you could have still went the variable way. $_SERVER['DOCUMENT_ROOT'] is your doc root. you could have used that, and worked forward from there. Quote Link to comment 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.