StefanRSA Posted November 10, 2009 Share Posted November 10, 2009 I have my root folder as: $root = $_SERVER["SITE_HTMLROOT"]; // the server root Why does this not work when I want to include a php file: include "$root/form.php"; But the link to an image work like: <img src="<?echo $root;?>/images/pic1.gif"> on the same form??? Link to comment https://forums.phpfreaks.com/topic/180955-solved-include-problem/ Share on other sites More sharing options...
iversonm Posted November 10, 2009 Share Posted November 10, 2009 I would personally use $root=$_SERVER['HTTP_HOST'] I feel like that would work better Try that out and let me know Link to comment https://forums.phpfreaks.com/topic/180955-solved-include-problem/#findComment-954712 Share on other sites More sharing options...
StefanRSA Posted November 10, 2009 Author Share Posted November 10, 2009 Ouch! No, now nothing works??? Had to revert back to the old one but the include still dont work Link to comment https://forums.phpfreaks.com/topic/180955-solved-include-problem/#findComment-954719 Share on other sites More sharing options...
Adam Posted November 10, 2009 Share Posted November 10, 2009 What do you get when you echo out $root/form.php? Remember the document root is not the same as the server root. Link to comment https://forums.phpfreaks.com/topic/180955-solved-include-problem/#findComment-954720 Share on other sites More sharing options...
iversonm Posted November 10, 2009 Share Posted November 10, 2009 well see with http_host is work include the the http:// so if your url is http://www.google.com/test.php http_host will return www.google.com i know that with include you can just do something like this include "form.php"; or if its higher up include "include/form.php"; Link to comment https://forums.phpfreaks.com/topic/180955-solved-include-problem/#findComment-954721 Share on other sites More sharing options...
StefanRSA Posted November 10, 2009 Author Share Posted November 10, 2009 I get: "/newadfield.php" when I echo "$root/form.php"; Link to comment https://forums.phpfreaks.com/topic/180955-solved-include-problem/#findComment-954724 Share on other sites More sharing options...
StefanRSA Posted November 10, 2009 Author Share Posted November 10, 2009 It works if I use: include $root.'newadfield.php'; Is this correct or should I leave the $root out? Link to comment https://forums.phpfreaks.com/topic/180955-solved-include-problem/#findComment-954726 Share on other sites More sharing options...
Adam Posted November 10, 2009 Share Posted November 10, 2009 Yeah, you're basically trying to include the file from the server root. After a quick Google search found this, only skimmed through it quickly but should explain it to you.. http://www.communitymx.com/content/article.cfm?cid=230ad Link to comment https://forums.phpfreaks.com/topic/180955-solved-include-problem/#findComment-954727 Share on other sites More sharing options...
StefanRSA Posted November 10, 2009 Author Share Posted November 10, 2009 Thanks Guys! Link to comment https://forums.phpfreaks.com/topic/180955-solved-include-problem/#findComment-954728 Share on other sites More sharing options...
iversonm Posted November 10, 2009 Share Posted November 10, 2009 here is why $_SERVER["SITE_HTMLROOT"]; doesnt actually exist. if you add error_reporting(E_ALL); You will see it throws an error so when you did this. include $root.'newadfield.php'; $root was not set so it was the same thing as include 'newadfield.php'; which is why I said to leave $root out.. Make sense? Link to comment https://forums.phpfreaks.com/topic/180955-solved-include-problem/#findComment-954729 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.