php-pendejo Posted November 7, 2008 Share Posted November 7, 2008 ok here is what i am trying to do and i hope you all can help me... I have Mandrake Linux installed on one of my home pc's with lamp system on it. I have a portal script i created on my windows lamp pc that should basic work the same and it did but one thing... here is the code that is giving me an issue: ob_start(); $imp_file=implode("", file($filename)) ; $imp_file = addslashes($imp_file); eval($imp_file); $file_content = ob_get_contents(); ob_end_flush(); what i am trying to send to this code is and html file with lets say <table width = $width>. What I want the eval to do is to take $width and make lets say 55%. I have everything correct i think and I have tried many other examples on the net for evaluating a string but all i get is an error: Parse error: syntax error, unexpected T_STRING in /var/www/html/Public_Html/PhpCurciut/themes/Voyix/theme.php(147) : eval()'d code on line 1 now just to let you know the theme looks simular to php nuke (i have also tried to use the way they eval there themes), but it still gave the same error ex: $tmpl_file = "themes/$theme/content_page.html"; $thefile = implode("", file($tmpl_file)); $thefile = addslashes($thefile); $thefile = "\$r_file=\"".$thefile."\";"; eval($thefile); print $r_file; please help Im so lost lol Quote Link to comment https://forums.phpfreaks.com/topic/131843-eval-and-ob_start-stuff/ Share on other sites More sharing options...
trq Posted November 7, 2008 Share Posted November 7, 2008 Whats wrong with include? Quote Link to comment https://forums.phpfreaks.com/topic/131843-eval-and-ob_start-stuff/#findComment-684868 Share on other sites More sharing options...
php-pendejo Posted November 7, 2008 Author Share Posted November 7, 2008 include does not change $width to 55% it only includes the file but does not evaluate it Quote Link to comment https://forums.phpfreaks.com/topic/131843-eval-and-ob_start-stuff/#findComment-684875 Share on other sites More sharing options...
DarkWater Posted November 7, 2008 Share Posted November 7, 2008 It does if you use PHP tags in the proper place. *sigh* Quote Link to comment https://forums.phpfreaks.com/topic/131843-eval-and-ob_start-stuff/#findComment-684922 Share on other sites More sharing options...
php-pendejo Posted November 8, 2008 Author Share Posted November 8, 2008 ok what do you mean?? I even rewrote to see if i ha errors but all I get is the error... any code examples that i can try to see if what you say is correct? Quote Link to comment https://forums.phpfreaks.com/topic/131843-eval-and-ob_start-stuff/#findComment-685026 Share on other sites More sharing options...
DarkWater Posted November 8, 2008 Share Posted November 8, 2008 Try this so you can see what I mean: bad.php <b>$width</b> good.php <b><?php echo $width ?></b> include.php <?php $width = 55; echo "Width set up, test: $width<br />"; echo "Starting includes...<br />"; echo "bad.php:<br />"; include ('bad.php'); echo "<br />good.php:<br />"; include('good.php'); ?> Put all 3 of those files in the same folder and go to include.php. Quote Link to comment https://forums.phpfreaks.com/topic/131843-eval-and-ob_start-stuff/#findComment-685029 Share on other sites More sharing options...
php-pendejo Posted November 8, 2008 Author Share Posted November 8, 2008 maybe I should have said this before, i am trying to purse an html file. in this file is only html. what i want to use is eval() to evaluate the variables i have in this html file. now my thinking is if i read this html into a string, addslashes, then there should be no problems in evaluating that. Maybe i am wrong in this please prove me wrong... but for some reason i cant. Also the code works in widows but not on my linux box. I dont see any difference in configurations in either. and i tried your code and it gave me $width not 55. Quote Link to comment https://forums.phpfreaks.com/topic/131843-eval-and-ob_start-stuff/#findComment-685044 Share on other sites More sharing options...
DarkWater Posted November 8, 2008 Share Posted November 8, 2008 Funny, because I just tried it and got: Width set up, test: 55<br /> Starting includes...<br /> bad.php:<br /> <b>$width</b> <br /> good.php:<br /> <b>55</b> Quote Link to comment https://forums.phpfreaks.com/topic/131843-eval-and-ob_start-stuff/#findComment-685046 Share on other sites More sharing options...
php-pendejo Posted November 8, 2008 Author Share Posted November 8, 2008 so no suggestions? cause its not working for me. Quote Link to comment https://forums.phpfreaks.com/topic/131843-eval-and-ob_start-stuff/#findComment-685064 Share on other sites More sharing options...
sasa Posted November 8, 2008 Share Posted November 8, 2008 try <?php $width = 55; $a = '<table width="$width%">'; $a = addslashes($a); eval('$out = "'.$a.'";'); echo $out; ?> Quote Link to comment https://forums.phpfreaks.com/topic/131843-eval-and-ob_start-stuff/#findComment-685148 Share on other sites More sharing options...
wildteen88 Posted November 8, 2008 Share Posted November 8, 2008 maybe I should have said this before, i am trying to purse an html file. in this file is only html. what i want to use is eval() to evaluate the variables i have in this html file. now my thinking is if i read this html into a string, addslashes, then there should be no problems in evaluating that. Maybe i am wrong in this please prove me wrong... but for some reason i cant. Also the code works in widows but not on my linux box. I dont see any difference in configurations in either. and i tried your code and it gave me $width not 55. PHP will parse any PHP code within any file that is being included, Provided you place all PHP code within PHP tags. So if your .html file is this: <table width="<?php echo $width; ?>"> And you're using the the following code to include your .html file <?php $width = 55; include 'myfile.html'; ?> The output will be <table width="55"> You do not need to use output buffering/eval to parse the contents of an .html file that is being included. Quote Link to comment https://forums.phpfreaks.com/topic/131843-eval-and-ob_start-stuff/#findComment-685238 Share on other sites More sharing options...
php-pendejo Posted November 8, 2008 Author Share Posted November 8, 2008 ok I understand what everyone is telling me. maybe its me not explaining it correctly. I include it and it gives me the same thing, I eval it or i use ob_whatever it still gives me the samething. here is the questiong i should have asked: is there something that turns the function on and off or another function i could use or i dont know another trick some one can give me??? Quote Link to comment https://forums.phpfreaks.com/topic/131843-eval-and-ob_start-stuff/#findComment-685373 Share on other sites More sharing options...
wildteen88 Posted November 8, 2008 Share Posted November 8, 2008 Post your code here. Make sure the parent file (the one that is including your .html file is a .php file). All the suggestions posted here should work for you. Quote Link to comment https://forums.phpfreaks.com/topic/131843-eval-and-ob_start-stuff/#findComment-685406 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.