/    Sign up×
Community /Pin to ProfileBookmark

include Parse error

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/john5115/public_html/site3/includes/include.php on line 35

im basically rebuilding my website and i am striping it down from about 100000 php files to about 5 or 6 just to make it easier for me to keep tabs on and update/change design.

i get the above error with the script below from my include file. it worked fine when it ran directly from the index.php but now its causing problems with it being in the include ?

[code=php]
<?php require_once “includes/connection.php”; ?>
<?
//Diary entrys for the home page:
$home = <<<HOMEDIARY

<table style=”width:100%; border:0; padding:0;” cellpadding=”0″ cellspacing=”0″>
<tr>
<td style=”height:37px; width:300px; background-image: url(images/left_top.gif);” colspan=”3″></td>
<td style=”height:37px; width:397px; background-image: url(images/right_top.gif);” colspan=”3″></td>
</tr>
<tr>
<td style=”height:235px; width:11px; background-image: url(images/line_left.gif); background-repeat:repeat-y”></td>
<!– beginning of text left –>
<td style=”width:284px;” valign=”top”>

$query = ‘SELECT * FROM diary ORDER BY diary_no DESC’;
$result = mysql_query($query, $link);
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo(‘<p>’ . {$row[“diary_date”]} . ‘</p> <p>’ . {$row[“diary_text”]} . ‘</p>’);
}

</td>
<!– end of text left –>
<td style=”height:235px; width:6px; background-image: url(images/line_center_left.gif); background-repeat:repeat-y”></td>
<td style=”height:235px; width:5px; background-image: url(images/line_center_right.gif); background-repeat:repeat-y”></td>
<!– beginning of text right –>
<td style=”width:381px;” valign=”top”>

$query = ‘SELECT * FROM cpg135_pictures ORDER BY RAND() LIMIT 1’;
$result = mysql_query($query, $link);
$row = mysql_fetch_array($result, MYSQL_ASSOC);

<a href=”../coppermine/” title=”knowj.com gallery”>
<img src=”http://www.knowj.com/coppermine/albums/ echo {$row[‘filepath’]}; if (!$row[‘filepath’]==’mobile’) {echo ‘normal_’;} echo $row[‘filename’]” width=”377″ style=”border:2px solid”> //line 35
</a>
</td>
<!– end of text right –>
<td style=”height:235px; width:11px; background-image: url(images/line_right.gif); background-repeat:repeat-y”></td>
</tr>
<tr>
<td style=”height:22px; width:303px; background-image: url(images/line_bottom_left.gif);” colspan=”3″ ></td>
<td style=”height:22px; width:397px; background-image: url(images/line_bottom_right.gif);” colspan=”3″></td>
</tr>
</table>

HOMEDIARY;
?>
[/code]

thanks in advance

to post a comment
PHP

9 Comments(s)

Copy linkTweet thisAlerts:
@chazzyDec 22.2005 — you can't do this, for one thing:
[code=php]
$home = echo("home");
[/code]


and i think the error is because you have a blank line after HOMEDIARY
Copy linkTweet thisAlerts:
@NogDogDec 22.2005 — First thing I see is that it appears you are trying to execute PHP commands from within your heredoc (<<<) string. You'll need to terminate your string and go back into normal PHP command lines at those points.
Copy linkTweet thisAlerts:
@knowjauthorDec 22.2005 — First thing I see is that it appears you are trying to execute PHP commands from within your heredoc (<<<) string. You'll need to terminate your string and go back into normal PHP command lines at those points.[/QUOTE]

i dont get what you mean.

could ii exit then reenter the <<<HOMEDIARY

or would i just have to enter and exit the php when needed?
Copy linkTweet thisAlerts:
@NogDogDec 22.2005 — [code=php]
<?php
echo <<<EOD
This is just string data being output to browser.
It's OK to have a $variable in it.
If it's an {$array['element']} you should have it in curly braces
EOD;

echo "Now I can do a normal PHP command, like these.";
echo date('Y/m/d');

echo <<<EOD
Now I'm outputting more text,
with $variables and {$array['elements']} if desired,
but no PHP commands or functions until after I end this
EOD;

echo "Back to PHP commands and functions here.";
?>
[/code]
Copy linkTweet thisAlerts:
@knowjauthorDec 22.2005 — will that still include it all within the $home variable tho as the whole point of it was to assign all of that script to the $home variable then echo it under an if statement in index.php
Copy linkTweet thisAlerts:
@NogDogDec 22.2005 — Oops, sorry, didn't see that you were assigning it. Do this, instead:
[code=php]
<?php
$home = <<<EOD
This is just string data being output to browser.
It's OK to have a $variable in it.
If it's an {$array['element']} you should have it in curly braces
EOD;

# Now I can append using .= and any PHP function:
$home .= date('Y/m/d');

# now add some more text using .= again:
$home .= <<<EOD
Now I'm outputting more text,
with $variables and {$array['elements']} if desired,
but no PHP commands or functions until after I end this
EOD;

# append some more PHP output:
$home .= stripslashes($_POST['name']);
?>
[/code]
Copy linkTweet thisAlerts:
@knowjauthorDec 22.2005 — iv got this sofar wether its right or not i dont know

the one line i dont have a clue with is

[code=php]$home .= <img src="http://www.knowj.com/coppermine/albums/ echo {$row['filepath']}; if (!{$row['filepath']}=='mobile') {echo 'normal_';} echo {$row['filename']}; " width='377' style='border:2px solid'>[/code]

as it got html and php and its not just simple variables which can be encased in {}

[code=php]
<?php require_once "includes/connection.php"; ?>
<?
//Diary entrys for the home page:
$home = <<<HOMEDIARY
<table style="width:100%; border:0; padding:0;" cellpadding="0" cellspacing="0">
<tr>
<td style="height:37px; width:300px; background-image: url(images/left_top.gif);" colspan="3"></td>
<td style="height:37px; width:397px; background-image: url(images/right_top.gif);" colspan="3"></td>
</tr>
<tr>
<td style="height:235px; width:11px; background-image: url(images/line_left.gif); background-repeat:repeat-y"></td>
<!-- beginning of text left -->
<td style="width:284px;" valign="top">

$query = 'SELECT * FROM diary ORDER BY diary_no DESC';
$result = mysql_query($query, $link);
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo('<p>' . {$row["diary_date"]} . '</p> <p>' . {$row["diary_text"]} . '</p>');
}

</td>
<!-- end of text left -->
<td style="height:235px; width:6px; background-image: url(images/line_center_left.gif); background-repeat:repeat-y"></td>
<td style="height:235px; width:5px; background-image: url(images/line_center_right.gif); background-repeat:repeat-y"></td>
<!-- beginning of text right -->
<td style="width:381px;" valign="top">
HOMEDIARY;

$home .= $query = 'SELECT * FROM cpg135_pictures ORDER BY RAND() LIMIT 1';
$home .= $result = mysql_query($query, $link);
$home .= $row = mysql_fetch_array($result, MYSQL_ASSOC);
$home .= <img src="http://www.knowj.com/coppermine/albums/ echo {$row['filepath']}; if (!{$row['filepath']}=='mobile') {echo 'normal_';} echo {$row['filename']}; " width='377' style='border:2px solid'>

$home .= <<<HOMEDIARY
</td>
<!-- end of text right -->
<td style="height:235px; width:11px; background-image: url(images/line_right.gif); background-repeat:repeat-y"></td>
</tr>
<tr>
<td style="height:22px; width:303px; background-image: url(images/line_bottom_left.gif);" colspan="3" ></td>
<td style="height:22px; width:397px; background-image: url(images/line_bottom_right.gif);" colspan="3"></td>
</tr>
</table>
HOMEDIARY;
?>

[/code]
Copy linkTweet thisAlerts:
@NogDogDec 22.2005 — [code=php]
$home .= <<<EOD
<img src="http://www.knowj.com/coppermine/albums/{$row['filepath']}
EOD;

if ($row['filepath'] != 'mobile')
{
$home .= 'normal_';
}

$home .= <<<EOD
{$row['filename']}" width='377' style='border:2px solid'>
EOD;

[/code]
Copy linkTweet thisAlerts:
@knowjauthorDec 22.2005 — i did it like below in the end. i was thinking about it all wrong and didnt think that the actual functions didnt need to be stored in the $home variable as all they do is work out the other variables in the script so they will be set before the page is displayed (i need to start taking the word serverside litraly)
[code=php]
$query = 'SELECT * FROM cpg135_pictures ORDER BY RAND() LIMIT 1';
$result = mysql_query($query, $link);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
if (!$row['filepath']=='mobile')
{
$normal = 'normal_';
}

$home .= <<<HOMEDIARY
<!-- beginning of text right -->
<img src="http://www.knowj.com/coppermine/albums/{$row['filepath']}$normal{$row['filename']}" width="377" style="border:2px solid">
[/code]


thanks for the help i really appreciate it
×

Success!

Help @knowj spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...