MadnessRed Posted June 16, 2008 Share Posted June 16, 2008 OK, I have to directories, Uni1 and Uni2, I want any changes I make in uni1 to also be made in uni 2. So I have I file called index.php in the root of uni1, in uni2, in the root I have a file called index.php with this code. <?php //First lets find out what file this is $file = $_SERVER["SCRIPT_NAME"]; $parts = Explode('/', $file); $file = $parts[count($parts) - 1]; //Now lets list the possible file paths $root = "../uni1/"; $admin = "../../uni1/admin/"; $converter = "../../uni1/converter/"; $css = "../../uni1/css/"; $db = "../../uni1/db/"; $images = "../../uni1/images/"; $includes = "../../uni1/includes/"; $functions = "../../../uni1/includes/functions/"; $includes = "../../uni1/install/"; $languagefr = "../../../uni1/language/fr/"; $scripts = "../../uni1/scripts/"; $OpenGame = "../../../uni1/templates/OpenGame/"; //Now lets decide the path (This is the only bit that needs editing) $path = $root; //Now lets create the entire path $show = $path . $file //And finally lets display the file include '$show'; ?> however when I run it I get this error Parse error: syntax error, unexpected T_INCLUDE in /home/www/uogame.co.cc/uni2/test.php on line 28 Line 28 is... include '$show'; If anyone can help I would be grateful. From what I can work out my self, the problem is that it doesn't like including a variable. Quote Link to comment https://forums.phpfreaks.com/topic/110413-unexpected-t_include-whem-using-a-variable/ Share on other sites More sharing options...
.josh Posted June 16, 2008 Share Posted June 16, 2008 for your error: $show = $path . $file need a ; after $file also, include '$show'; single quotes will interpret $show literally you need to use double quotes " " for it to interpret it as a var Quote Link to comment https://forums.phpfreaks.com/topic/110413-unexpected-t_include-whem-using-a-variable/#findComment-566449 Share on other sites More sharing options...
MadnessRed Posted June 16, 2008 Author Share Posted June 16, 2008 wow, thansk for the quick responce Thats fixed it The 's where there because before it had brackets and i just changed them, I didn't think there was a difference between ' and " Quote Link to comment https://forums.phpfreaks.com/topic/110413-unexpected-t_include-whem-using-a-variable/#findComment-566450 Share on other sites More sharing options...
.josh Posted June 16, 2008 Share Posted June 16, 2008 wow, thansk for the quick responce Thats fixed it The 's where there because before it had brackets and i just changed them, I didn't think there was a difference between ' and " everything inside a single quote ' ' is interpreted literally. Variables and escape chars like \n for new line will echo out like you meant to write the name, not the value or instruction behind it. A common use for this is say...giving code examples. everything in a double quote " " is interpreted figuratively. PHP will recognize that when you put $blah you mean to put the value of $blah not the name of the variable. Or if you do like \n PHP knows that you mean to make a new line. Quote Link to comment https://forums.phpfreaks.com/topic/110413-unexpected-t_include-whem-using-a-variable/#findComment-566459 Share on other sites More sharing options...
MadnessRed Posted June 16, 2008 Author Share Posted June 16, 2008 ok its worked when i tested it with jsut an echo, but when i tried it and put it into allt eh files I got this Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 3840 bytes) in /home/www/uogame.co.cc/uni2/common.php on line 28 Dunno if its related but the mysql database is limited to 16mb Quote Link to comment https://forums.phpfreaks.com/topic/110413-unexpected-t_include-whem-using-a-variable/#findComment-566696 Share on other sites More sharing options...
MadnessRed Posted June 17, 2008 Author Share Posted June 17, 2008 I have used <?php ini_set("memory_limit","20M"); that displayed the same error, on taking it to 30 i got an error 500 Quote Link to comment https://forums.phpfreaks.com/topic/110413-unexpected-t_include-whem-using-a-variable/#findComment-567637 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.