Jump to content
xisto Community
Sign in to follow this  
Raptrex

Php Parse Error Including Variable in post

Recommended Posts

ok this is my config script that runs my site:

<?# Set up info for left column on the top page:# It should begin with html tag <td> and finish with tag </td>$top_leftcol="<td width='195' bgcolor='#eeeeee'  valign='top'><table width='100%'  bgcolor='#777799' border=0 cellspacing='0' cellpadding='0'><tr><td> <font FACE='ARIAL, HELVETICA' color='#ffffff' size='-1'>   <b>MMORPG Trade Center</b></font><TABLE  WIDTH='100%'   border='0' cellspacing='1' cellpadding='4' ><tr><td bgcolor='#ffffff'> <font FACE='ARIAL, HELVETICA' color='#000099' size='-1'><P ALIGN='JUSTIFY'>Welcome to MMORPG Trade Center. Please post your in game item only in the correct game section.</td></tr></table></td></tr></table><p><table width='100%'  bgcolor='#777799' border=0 cellspacing='0' cellpadding='0'><tr><td> <font FACE='ARIAL, HELVETICA' color='#ffffff' size='-1'>  <b>News</b></font><TABLE  WIDTH='100%'   border='0' cellspacing='1' cellpadding='4' ><tr><td bgcolor='#ffffff'> <font FACE='ARIAL, HELVETICA' color='#000099' size='-1'>News Goes Here<P ALIGN='JUSTIFY'></font></td></tr></table></td></tr></table><p><table width='100%'  bgcolor='#777799' border=0 cellspacing='0' cellpadding='0'><tr><td> <font FACE='ARIAL, HELVETICA' color='#ffffffff' size='-1'>  <b>Other</b></font><TABLE  WIDTH='100%'   border='0' cellspacing='1' cellpadding='4' ><tr><td bgcolor='#ffffff'> <font FACE='ARIAL, HELVETICA' color='#000099' size='-1'><P ALIGN='JUSTIFY'>Other Links Goes Here</font></td></tr></table></td></tr></table></td>"; ?>

acutally i didnt write this but heres my problem

<font FACE='ARIAL, HELVETICA' color='#000099' size='-1'>News Goes Here<P ALIGN='JUSTIFY'>

where is says "News goes here" how can i add php to include a file cuz i get this error

Parse error: parse error, unexpected T_STRING in /home/raptrex/public_html/trade/config.php on line 215

when i add that
<?php include "showonline.php"; ?>

i tried taking out the <?php ?> tags

and i still get the parse error

plz help

Share this post


Link to post
Share on other sites

Okay, you tried putting <?php stuff ?> inside a string. So if you wanted to include output from a script you'd have to do something like:

<?php$string="things".(include('showonline.php'))."more things";?>
instead of
<?php$string="things <?php include('showonline.php'); ?>."more things";?>

Secondly, you seem to have spotted the problem yourself, whether or not you try to include showonline.php, you still get an error. In fact, no matter what you do, you get an error in config.php. Clearly the error lies in config.php.

So, I suggest you check where line 215 would be and see what you are doing there. It might be that you have to escape quotation marks or something like that. Try replacing all ' with \"

Share this post


Link to post
Share on other sites

It is not possible to have include ""; inside a variable. One way you could still have this is by using a function() instead.

I am going to create a function called top_leftool to replace your variable $top_leftool. Now instead of writing $top_leftool when you write this text just write top_leftool() instead!

Here is the code:

<?// Set up info for left column on the top page:// It should begin with html tag <td> and finish with tag </td>function top_leftool() {echo "<td width='195' bgcolor='#eeeeee'  valign='top'><table width='100%'  bgcolor='#777799' border=0 cellspacing='0' cellpadding='0'><tr><td> <font FACE='ARIAL, HELVETICA' color='#ffffff' size='-1'>  <b>MMORPG Trade Center</b></font><TABLE  WIDTH='100%'   border='0' cellspacing='1' cellpadding='4' ><tr><td bgcolor='#ffffff'> <font FACE='ARIAL, HELVETICA' color='#000099' size='-1'><P ALIGN='JUSTIFY'>Welcome to MMORPG Trade Center. Please post your in game item only in the correct game section.</td></tr></table></td></tr></table><p><table width='100%'  bgcolor='#777799' border=0 cellspacing='0' cellpadding='0'><tr><td> <font FACE='ARIAL, HELVETICA' color='#ffffff' size='-1'> <b>News</b></font><TABLE  WIDTH='100%'   border='0' cellspacing='1' cellpadding='4' ><tr><td bgcolor='#ffffff'> <font FACE='ARIAL, HELVETICA' color='#000099' size='-1'> ";/* Now lets stop writing the first part and INCLUDE the news */include "showonline.php";/* Great, we've included the news so lets carry of writing! */echo "<P ALIGN='JUSTIFY'></font></td></tr></table></td></tr></table><p><table width='100%'  bgcolor='#777799' border=0 cellspacing='0' cellpadding='0'><tr><td> <font FACE='ARIAL, HELVETICA' color='#ffffffff' size='-1'> <b>Other</b></font><TABLE  WIDTH='100%'   border='0' cellspacing='1' cellpadding='4' ><tr><td bgcolor='#ffffff'> <font FACE='ARIAL, HELVETICA' color='#000099' size='-1'><P ALIGN='JUSTIFY'>Other Links Goes Here</font></td></tr></table></td></tr></table></td>"; } /* End the function */?>


That should be it. Just right top_leftool() where you want the news to go :rolleyes:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.