leijae Posted July 5, 2011 Share Posted July 5, 2011 $desc = include($path/$file/descriptions.txt); echo "<div class='sshot'><img src='$path/$file/screenshot.jpg' /><div class='randcont'> $desc </div>"; i've tried concatenation and: echo "<div class='sshot'><img src='$path/$file/screenshot.jpg' /></div><div class='randcont'>"; include($path/$file/descriptions.txt); echo "</div>"; errors: Warning: Division by zero in C:\xampp\htdocs\project\include\vars.php on line 21 Notice: Use of undefined constant descriptions - assumed 'descriptions' in C:\xampp\htdocs\project\include\vars.php on line 21 Warning: Division by zero in C:\xampp\htdocs\project\include\vars.php on line 21 Notice: Use of undefined constant txt - assumed 'txt' in C:\xampp\htdocs\project\include\vars.php on line 21 Warning: include(txt) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\project\include\vars.php on line 21 Warning: include() [function.include]: Failed opening 'txt' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\project\include\vars.php on line 21 Quote Link to comment https://forums.phpfreaks.com/topic/241145-using-include-within-an-echo-as-variable/ Share on other sites More sharing options...
AyKay47 Posted July 5, 2011 Share Posted July 5, 2011 wrap your include in quotes include("$path/$file/descriptions.txt"); Quote Link to comment https://forums.phpfreaks.com/topic/241145-using-include-within-an-echo-as-variable/#findComment-1238662 Share on other sites More sharing options...
Pikachu2000 Posted July 5, 2011 Share Posted July 5, 2011 Try putting the path in double quotes. $desc = include("$path/$file/descriptions.txt"); Quote Link to comment https://forums.phpfreaks.com/topic/241145-using-include-within-an-echo-as-variable/#findComment-1238663 Share on other sites More sharing options...
leijae Posted July 5, 2011 Author Share Posted July 5, 2011 wow, i feel like an idiot. thanks that fixed it! Quote Link to comment https://forums.phpfreaks.com/topic/241145-using-include-within-an-echo-as-variable/#findComment-1238669 Share on other sites More sharing options...
AbraCadaver Posted July 5, 2011 Share Posted July 5, 2011 And just to preempt your next post, you'll probably want file_get_contents() instead of include. Quote Link to comment https://forums.phpfreaks.com/topic/241145-using-include-within-an-echo-as-variable/#findComment-1238671 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.