Page 1 of 3
error i dont understand
Posted: Fri Nov 25, 2005 11:52 am
by gaogier
what is this error line asking?:
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/gaming/public_html/index.php on line 83
Posted: Fri Nov 25, 2005 11:56 am
by Burrito
it would be better and easier for us to help you if you post your code that is generating that error.
Posted: Fri Nov 25, 2005 11:56 am
by neophyte
I think you're missing a ";" or a string was not ended somewhere correctly.
Posted: Fri Nov 25, 2005 12:00 pm
by gaogier
/* if we aren't displaying all news,
* then give a link to do so */
i was just trying to workout what the error was asking so i dont have to come back here and ask again, but if this helps then i understand, sorry
Posted: Fri Nov 25, 2005 12:05 pm
by Burrito
that snippet you posted should not generate an error. My guess is (if that's line 83) you have a problem with the line directly above it....probably as neophyte suggested, you're missing a semicolon ";".
Posted: Fri Nov 25, 2005 12:06 pm
by gaogier
where abouts should i put it?
i have deleted the code, and it now has the error on like 84
just getting the bottem half of the code
Posted: Fri Nov 25, 2005 12:08 pm
by Burrito
the line above it if it's some kind of declaration statement, it needs a semicolon to end it.
but your best bet....ummm...post more code

Posted: Fri Nov 25, 2005 12:09 pm
by gaogier
Jcart | Please use Code: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Code: Select all
</div><br />
<?php
}
/* if we aren't displaying all news,
* then give a link to do so */
if ($all == 0) {
echo "<center><a href=\"{$_SERVER['PHP_SELF']}" .
"?action=all\">View all news</a></center>\n";
}else{
echo '<center><a href="'.$_SERVER['PHP_SELF'].'">View recent news only</a></center>';
}
}
Jcart | Please use Code: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Posted: Fri Nov 25, 2005 12:12 pm
by neophyte
Code: Select all
echo "<center><a href=\"{$_SERVER['PHP_SELF']}?action=all\">View all news</a></center>\n";
I think that will do it.
Posted: Fri Nov 25, 2005 12:31 pm
by Jenk
post the entire page pls.
Neophyte - no, that won't be it.
Posted: Fri Nov 25, 2005 2:57 pm
by trukfixer
Neophyte is correct - try it
look carefully at the code - note how the quotes are placed, and the type of quoting
If you do $array['value'] *INSIDE* of a quoted string, you get that error
He either needs to do :
Code: Select all
echo "<center><a href=\"".$_SERVER['PHP_SELF']."?action=all\">View all news</a></center>\n";
OR
Code: Select all
echo "<center><a href='$_SERVER[PHP_SELF]?action=all'>View all news</a></center>\n";
Posted: Fri Nov 25, 2005 3:07 pm
by Jenk
Here is his original, in php highlighting:
Code: Select all
echo '<center><a href="'.$_SERVER['PHP_SELF'].'">View recent news only</a></center>';
Which is syntactically correct.
The error is
above that anyway, so it is most definately not that line causing the error.
And to get around the $var['abc'] inside a double quoted string, use braces:
In a literal string (single quotes) you'll get exactly what you type.
Posted: Fri Nov 25, 2005 3:48 pm
by gaogier
still get the same error
Code: Select all
<?php
# News Db script - index.php
function displayNews($all = 0) {
global $sitestyle;
require_once ('../mysql_connect1.php');//connect to db
if ($all == 0) {
$topic_query = "SELECT * FROM `ipb_topics` WHERE `forum_id`= '1' ORDER BY `topic_time` DESC LIMIT 7"; // do topic query
}else{
$topic_query = "SELECT * FROM `ipb_topics` WHERE `forum_id`= '63' ORDER BY `topic_time` DESC"; // do topic query
}
$topic_result = mysql_query ($topic_query);
while ($topic_row = mysql_fetch_assoc($topic_result)) {
$tt = $topic_row['topic_time'];
$topic = $topic_row['topic_id'];
$poster = $topic_row['topic_poster'];
$first = $topic_row['topic_first_post_id'];
$title = $topic_row['topic_title'];
$topic_replies = $topic_row['topic_replies'];
$post_query = "SELECT * FROM `ipb_posts` WHERE `topic_id` = '$topic' AND `poster_id` = '$poster' AND `post_id` = '$first'"; // do post subject query
$post_result = mysql_query($post_query);
while ($post_row = mysql_fetch_assoc($post_result)){
$post_id = $post_row['post_id'];
}
$use_query = "SELECT `username`, `user_avatar`, `user_email`, `user_rank` FROM `ipb_users` WHERE `user_id` = '$poster'"; // do user query
$use_result = mysql_query($use_query);
while ($use_row = mysql_fetch_assoc($use_result)){
$user = $use_row['username'];
$user_avatar = $use_row['user_avatar'];
$user_email = $use_row['user_email'];
$rank = $use_row['user_rank'];
}
$news_query = "SELECT `post_text` FROM `ipb_posts_text` WHERE `post_id`='$post_id'";
$news_result = mysql_query($news_query);
while ($news_row = mysql_fetch_assoc($news_result)){
$news = $news_row['post_text'];
}
$rank_result = mysql_query("SELECT `rank_title` FROM `ibp_ranks` WHERE `rank_id`='$rank'");
while($rank_row = mysql_fetch_assoc($rank_result)){
$ranks = $rank_row['rank_title'];
}
$date = date("D M jS, Y g:i a", $tt);
if ($topic_replies == 0){
$reply = '<a href="http://www.nozhosting.com/forums/posting.php?mode=reply&t='.$topic.'">Nobody has commented on this piece of news yet. Be the first!</a>';
$post_new ="";
}else{
$reply = 'comments(<a href="http://www.nozhosting.com/forums/viewtopic.php?t='.$topic.'">'.$topic_replies.'</a>) |';
$post_new = '<a href="http://www.nozhosting.com/forums/posting.php?mode=reply&t='.$topic.'">Post a comment</a>';
}
'.$news;
}else{
$news1 = $news;
}
// Replace newlines //
$news2 = str_replace("\n", "\n<br />\n", $news1);
?>
<table border="0" cellpadding="0" cellspacing="0" width="100%" class="news">
<tr>
<td></td>
<td><div align="center"><p class="small2"><a href="http://www.nozhosting.com/forums/viewtopic.php?t=<?php echo $topic; ?>" class="news"><?php echo $title; ?></a> posted by <a href="http://www.nozhosting.com/forums/profile.php?mode=viewprofile&u=<?php echo $poster; ?>"><?php echo $user; ?></a> on <?php echo $date;?></p></font></div></td>
<td height="25" width="30"></td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="16"></td>
<td align="center" border="0" cellpadding="0" cellspacing="0">
<img src="<?php echo $user_avatar; ?>" ><br /><center><font class="small2"><b><?php echo $ranks; ?></b></font></center></td>
<td width="429"> <p><font class="small2">
<p><?php echo $news2; ?></p><br>
<br /><font class="small2"><?php echo $reply. ' '. $post_new;?>
</td>
</tr>
</table>
</div><br />
<?php
}
/* if we aren't displaying all news,
* then give a link to do so */
if ($all == 0) {
echo "<center><a href=\"{$_SERVER['PHP_SELF']}" .
"?action=all\">View all news</a></center>\n";
}else{
echo "<center><a href=\"".$_SERVER['PHP_SELF']."?action=all\">View all news</a></center>\n";
}
}
echo "<CENTER>\n";
switch($_GET['action']) {
case 'all':
displayNews(1);
break;
default:
displayNews();
}
echo "</CENTER>\n";
?>
Posted: Fri Nov 25, 2005 4:09 pm
by Jenk
for the love of god, please post ALL of your code on that page!
Posted: Fri Nov 25, 2005 5:19 pm
by gaogier
there