Forum Moderators: coopster
Parse error: parse error, unexpected $ in /........./phpBB2/includes/usercp_register.php on line 1401[/b]
Here is around the lines (1401) in question, I'm pretty new to all this so I'm not sure what to look at or do, any help would be appreciated, considering I can't register any new users until I get this figured out. Here is the lines in question:
if ( $mode!= 'register' )
{
if ( $userdata['user_allowavatar'] && ( $board_config['allow_avatar_upload'] ¦¦ $board_config['allow_avatar_local'] ¦¦ $board_config['allow_avatar_remote'] ) )
{
$template->assign_block_vars('switch_avatar_block', array() );
if ( $board_config['allow_avatar_upload'] && file_exists(@phpbb_realpath('./' . $board_config['avatar_path'])) )
{
if ( $form_enctype!= '' )
{
$template->assign_block_vars('switch_avatar_block.switch_avatar_local_upload', array() );
}
$template->assign_block_vars('switch_avatar_block.switch_avatar_remote_upload', array() );
}
if ( $board_config['allow_avatar_remote'] )
{
$template->assign_block_vars('switch_avatar_block.switch_avatar_remote_link', array() );
}
if ( $board_config['allow_avatar_local'] && file_exists(@phpbb_realpath('./' . $board_config['avatar_gallery_path'])) )
{
$template->assign_block_vars('switch_avatar_block.switch_avatar_local_gallery', array() );
}
}
}
}
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
[/b]
Parse error: parse error, unexpected $ in /home/httpd/vhosts/example.com/httpdocs/phpBB2/includes/usercp_register.php on line 1432
I have no idea what unexpected $ means......
Well here is the line in question as well as the line above it and the line below it:
{
$template->assign_block_vars('switch_avatar_block.switch_avatar_remote_link', array() );
}
Line in question ---->if ( $board_config['allow_avatar_local'] && file_exists(@phpbb_realpath('./' . $board_config['avatar_gallery_path'])) )
{
}
$template->assign_block_vars('switch_avatar_block.switch_avatar_local_gallery', array() );
I hope someone can help, I can't register any new members until I get this figured out.....Thanks in advance.
[edited by: jatar_k at 2:02 am (utc) on Oct. 9, 2004]
[edit reason] generalized [/edit]
I compared code from my phpbb with yours in the first post.
It is exactly the same and mine works, you are getting an error trickling down from somewhere above the code that you posted I bet.
have you changed this file? If you have you should go back through your changes until it works again and then go forward one change at a time. the line number in mine that corresponds with that line is 1015 so I assume yours is mod'ed differently than mine.
<added>you might want to look at the massive array created right before these lines and see if there is a quote mismatch or some such there.
the whole piece of code you posted in the first message is fine.
What happens with parse erorrs is sometimes strange. What occurs we often refer to as trickle down.
Think of your code as a clear stream, if you drop something into it to cloud it, it doesn't always stop where it is. Most times it will 'trickle down' the stream until it gets caught on something. that isn't the spot where it entered, only the spot where it stopped.
Parse errors don't always corrupt your code right where they occur, they often throw off the flow until it, eventually, causes a mismatch later on.
When a line doesn't actually contain an error we start with that line and work our way up. We back track through the code, testing and measuring until we find the offending piece.
So you need to follow your code upwards until you can find the spot where things start to go wrong.
somewhere after 4500 posts you start to talk like Yoda ;)
<?php
/***************************************************************************
* usercp_viewprofile.php
* -------------------
* begin : Saturday, Feb 13, 2001
* copyright : (C) 2001 The phpBB Group
* email : support@phpbb.com
*
* $Id: usercp_viewprofile.php,v 1.5.2.2 2004/07/11 16:46:20 acydburn Exp $
*
*
***************************************************************************//***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*
***************************************************************************/if (!defined('IN_PHPBB') )
{
die("Hacking attempt");
exit;
}if ( empty($HTTP_GET_VARS[POST_USERS_URL]) ¦¦ $HTTP_GET_VARS[POST_USERS_URL] == ANONYMOUS )
{
message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']);
}
$profiledata = get_userdata($HTTP_GET_VARS[POST_USERS_URL]);$sql = "SELECT *
FROM " . RANKS_TABLE . "
ORDER BY rank_special, rank_min";
if (!($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain ranks information', '', __LINE__, __FILE__, $sql);
}$ranksrow = array();
while ( $row = $db->sql_fetchrow($result) )
{
$ranksrow[] = $row;
}
$db->sql_freeresult($result);//
// Output page header and profile_view template
//
$template->set_filenames(array(
'body' => 'profile_view_body.tpl')
);
make_jumpbox('viewforum.'.$phpEx);//
// Calculate the number of days this user has been a member ($memberdays)
// Then calculate their posts per day
//
$regdate = $profiledata['user_regdate'];
$memberdays = max(1, round( ( time() - $regdate ) / 86400 ));
$posts_per_day = $profiledata['user_posts'] / $memberdays;// Get the users percentage of total posts
if ( $profiledata['user_posts']!= 0 )
{
$total_posts = get_db_stat('postcount');
$percentage = ( $total_posts )? min(100, ($profiledata['user_posts'] / $total_posts) * 100) : 0;
}
else
{
$percentage = 0;
}$avatar_img = '';
if ( $profiledata['user_avatar_type'] && $profiledata['user_allowavatar'] )
{
switch( $profiledata['user_avatar_type'] )
{
case USER_AVATAR_UPLOAD:
$avatar_img = ( $board_config['allow_avatar_upload'] )? '<img src="' . $board_config['avatar_path'] . '/' . $profiledata['user_avatar'] . '" alt="" border="0" />' : '';
break;
case USER_AVATAR_REMOTE:
$avatar_img = ( $board_config['allow_avatar_remote'] )? '<img src="' . $profiledata['user_avatar'] . '" alt="" border="0" />' : '';
break;
case USER_AVATAR_GALLERY:
$avatar_img = ( $board_config['allow_avatar_local'] )? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $profiledata['user_avatar'] . '" alt="" border="0" />' : '';
break;
}
}$poster_rank = '';
$rank_image = '';
if ( $profiledata['user_rank'] )
{
for($i = 0; $i < count($ranksrow); $i++)
{
if ( $profiledata['user_rank'] == $ranksrow[$i]['rank_id'] && $ranksrow[$i]['rank_special'] )
{
$poster_rank = $ranksrow[$i]['rank_title'];
$rank_image = ( $ranksrow[$i]['rank_image'] )? '<img src="' . $ranksrow[$i]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
}
}
}
else
{
for($i = 0; $i < count($ranksrow); $i++)
{
if ( $profiledata['user_posts'] >= $ranksrow[$i]['rank_min'] &&!$ranksrow[$i]['rank_special'] )
{
$poster_rank = $ranksrow[$i]['rank_title'];
$rank_image = ( $ranksrow[$i]['rank_image'] )? '<img src="' . $ranksrow[$i]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
}
}
}$temp_url = append_sid("privmsg.$phpEx?mode=post&" . POST_USERS_URL . "=" . $profiledata['user_id']);
$pm_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_pm'] . '" alt="' . $lang['Send_private_message'] . '" title="' . $lang['Send_private_message'] . '" border="0" /></a>';
$pm = '<a href="' . $temp_url . '">' . $lang['Send_private_message'] . '</a>';if (!empty($profiledata['user_viewemail']) ¦¦ $userdata['user_level'] == ADMIN )
{
$email_uri = ( $board_config['board_email_form'] )? append_sid("profile.$phpEx?mode=email&" . POST_USERS_URL .'=' . $profiledata['user_id']) : 'mailto:' . $profiledata['user_email'];$email_img = '<a href="' . $email_uri . '"><img src="' . $images['icon_email'] . '" alt="' . $lang['Send_email'] . '" title="' . $lang['Send_email'] . '" border="0" /></a>';
$email = '<a href="' . $email_uri . '">' . $lang['Send_email'] . '</a>';
}
else
{
$email_img = ' ';
$email = ' ';
}$www_img = ( $profiledata['user_website'] )? '<a href="' . $profiledata['user_website'] . '" target="_userwww"><img src="' . $images['icon_www'] . '" alt="' . $lang['Visit_website'] . '" title="' . $lang['Visit_website'] . '" border="0" /></a>' : ' ';
$www = ( $profiledata['user_website'] )? '<a href="' . $profiledata['user_website'] . '" target="_userwww">' . $profiledata['user_website'] . '</a>' : ' ';if (!empty($profiledata['user_icq']) )
{
$icq_status_img = '<a href="http://wwp.icq.com/' . $profiledata['user_icq'] . '#pager"><img src="http://web.icq.com/whitepages/online?icq=' . $profiledata['user_icq'] . '&img=5" width="18" height="18" border="0" /></a>';
$icq_img = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $profiledata['user_icq'] . '"><img src="' . $images['icon_icq'] . '" alt="' . $lang['ICQ'] . '" title="' . $lang['ICQ'] . '" border="0" /></a>';
$icq = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $profiledata['user_icq'] . '">' . $lang['ICQ'] . '</a>';
}
else
{
$icq_status_img = ' ';
$icq_img = ' ';
$icq = ' ';
}$aim_img = ( $profiledata['user_aim'] )? '<a href="aim:goim?screenname=' . $profiledata['user_aim'] . '&message=Hello+Are+you+there?"><img src="' . $images['icon_aim'] . '" alt="' . $lang['AIM'] . '" title="' . $lang['AIM'] . '" border="0" /></a>' : ' ';
$aim = ( $profiledata['user_aim'] )? '<a href="aim:goim?screenname=' . $profiledata['user_aim'] . '&message=Hello+Are+you+there?">' . $lang['AIM'] . '</a>' : ' ';$msn_img = ( $profiledata['user_msnm'] )? $profiledata['user_msnm'] : ' ';
$msn = $msn_img;$yim_img = ( $profiledata['user_yim'] )? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $profiledata['user_yim'] . '&.src=pg"><img src="' . $images['icon_yim'] . '" alt="' . $lang['YIM'] . '" title="' . $lang['YIM'] . '" border="0" /></a>' : '';
$yim = ( $profiledata['user_yim'] )? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $profiledata['user_yim'] . '&.src=pg">' . $lang['YIM'] . '</a>' : '';$temp_url = append_sid("search.$phpEx?search_author=" . urlencode($profiledata['username']) . "&showresults=posts");
$search_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_search'] . '" alt="' . $lang['Search_user_posts'] . '" title="' . $lang['Search_user_posts'] . '" border="0" /></a>';
$search = '<a href="' . $temp_url . '">' . $lang['Search_user_posts'] . '</a>';// Start add - Birthday MOD
if ($profiledata['user_birthday']!=999999)
{
$user_birthday = realdate($lang['DATE_FORMAT'], $profiledata['user_birthday']);
} else
{
$user_birthday = $lang['No_birthday_specify'];
}
// End add - Birthday MOD// Start add - Gender MOD
if (!empty($profiledata['user_gender']))
{
switch ($profiledata['user_gender'])
{
case 1: $gender=$lang['Male'];break;
case 2: $gender=$lang['Female'];break;
default:$gender=$lang['No_gender_specify'];
}
} else $gender=$lang['No_gender_specify'];
// End add - Gender MOD//
// Generate page
//
$page_title = $lang['Viewing_profile'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);$template->assign_vars(array(
'USERNAME' => $profiledata['username'],
'JOINED' => create_date($lang['DATE_FORMAT'], $profiledata['user_regdate'], $board_config['board_timezone']),
'POSTER_RANK' => $poster_rank,
'RANK_IMAGE' => $rank_image,
'POSTS_PER_DAY' => $posts_per_day,
'POSTS' => $profiledata['user_posts'],
'PERCENTAGE' => $percentage . '%',
'POST_DAY_STATS' => sprintf($lang['User_post_day_stats'], $posts_per_day),
'POST_PERCENT_STATS' => sprintf($lang['User_post_pct_stats'], $percentage),'SEARCH_IMG' => $search_img,
'SEARCH' => $search,
'PM_IMG' => $pm_img,
'PM' => $pm,
'EMAIL_IMG' => $email_img,
'EMAIL' => $email,
'WWW_IMG' => $www_img,
'WWW' => $www,
'ICQ_STATUS_IMG' => $icq_status_img,
'ICQ_IMG' => $icq_img,
'ICQ' => $icq,
'AIM_IMG' => $aim_img,
'AIM' => $aim,
'MSN_IMG' => $msn_img,
'MSN' => $msn,
'YIM_IMG' => $yim_img,
'YIM' => $yim,'LOCATION' => ( $profiledata['user_from'] )? $profiledata['user_from'] : ' ',
'OCCUPATION' => ( $profiledata['user_occ'] )? $profiledata['user_occ'] : ' ',
'INTERESTS' => ( $profiledata['user_interests'] )? $profiledata['user_interests'] : ' ',// Start add - Gender MOD
'GENDER' => $gender,
// End add - Gender MOD// Start add - Birthday MOD
'BIRTHDAY' => $user_birthday,
// End add - Birthday MOD
'AVATAR_IMG' => $avatar_img,'L_VIEWING_PROFILE' => sprintf($lang['Viewing_user_profile'], $profiledata['username']),
'L_ABOUT_USER' => sprintf($lang['About_user'], $profiledata['username']),
'L_AVATAR' => $lang['Avatar'],
'L_POSTER_RANK' => $lang['Poster_rank'],
'L_JOINED' => $lang['Joined'],
'L_TOTAL_POSTS' => $lang['Total_posts'],
'L_SEARCH_USER_POSTS' => sprintf($lang['Search_user_posts'], $profiledata['username']),
'L_CONTACT' => $lang['Contact'],
'L_EMAIL_ADDRESS' => $lang['Email_address'],
'L_EMAIL' => $lang['Email'],
'L_PM' => $lang['Private_Message'],
'L_ICQ_NUMBER' => $lang['ICQ'],
'L_YAHOO' => $lang['YIM'],
'L_AIM' => $lang['AIM'],
'L_MESSENGER' => $lang['MSNM'],
'L_WEBSITE' => $lang['Website'],
'L_LOCATION' => $lang['Location'],
'L_OCCUPATION' => $lang['Occupation'],
'L_INTERESTS' => $lang['Interests'],// Start add - Gender MOD
'L_GENDER' => $lang['Gender'],
// End add - Gender MOD// Start add - Birthday MOD
'L_BIRTHDAY' => $lang['Birthday'],
// End add - Birthday MOD'U_SEARCH_USER' => append_sid("search.$phpEx?search_author=" . urlencode($profiledata['username'])),
'S_PROFILE_ACTION' => append_sid("profile.$phpEx"))
);$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>
Perhaps we should take a few steps back - can you copy and paste:
- the exact error message from your board,
- the one line in question from the file file mentioned in the error message (not the whole file).
Then we'll start from there.
I'm getting:Parse error: parse error, unexpected $ in /......./phpBB2/includes/usercp_viewprofile.php on line 244
I used Jedit to see if I can figure it out, from what I've been able to figure, line #182 the first line in bold below is connected to line #244, the second line in bold below. Now I'm not sure what to look for between those 2 lines.
$template->assign_vars(array(
'USERNAME' => $profiledata['username'],
'JOINED' => create_date($lang['DATE_FORMAT'], $profiledata['user_regdate'], $board_config['board_timezone']),
'POSTER_RANK' => $poster_rank,
'RANK_IMAGE' => $rank_image,
'POSTS_PER_DAY' => $posts_per_day,
'POSTS' => $profiledata['user_posts'],
'PERCENTAGE' => $percentage . '%',
'POST_DAY_STATS' => sprintf($lang['User_post_day_stats'], $posts_per_day),
'POST_PERCENT_STATS' => sprintf($lang['User_post_pct_stats'], $percentage),
'SEARCH_IMG' => $search_img,
'SEARCH' => $search,
'PM_IMG' => $pm_img,
'PM' => $pm,
'EMAIL_IMG' => $email_img,
'EMAIL' => $email,
'WWW_IMG' => $www_img,
'WWW' => $www,
'ICQ_STATUS_IMG' => $icq_status_img,
'ICQ_IMG' => $icq_img,
'ICQ' => $icq,
'AIM_IMG' => $aim_img,
'AIM' => $aim,
'MSN_IMG' => $msn_img,
'MSN' => $msn,
'YIM_IMG' => $yim_img,
'YIM' => $yim,
'LOCATION' => ( $profiledata['user_from'] )? $profiledata['user_from'] : ' ',
'OCCUPATION' => ( $profiledata['user_occ'] )? $profiledata['user_occ'] : ' ',
'INTERESTS' => ( $profiledata['user_interests'] )? $profiledata['user_interests'] : ' ',
// Start add - Birthday MOD
'BIRTHDAY' => $user_birthday,
// End add - Birthday MOD
'AVATAR_IMG' => $avatar_img,
'L_VIEWING_PROFILE' => sprintf($lang['Viewing_user_profile'], $profiledata['username']),
'L_ABOUT_USER' => sprintf($lang['About_user'], $profiledata['username']),
'L_AVATAR' => $lang['Avatar'],
'L_POSTER_RANK' => $lang['Poster_rank'],
'L_JOINED' => $lang['Joined'],
'L_TOTAL_POSTS' => $lang['Total_posts'],
'L_SEARCH_USER_POSTS' => sprintf($lang['Search_user_posts'], $profiledata['username']),
'L_CONTACT' => $lang['Contact'],
'L_EMAIL_ADDRESS' => $lang['Email_address'],
'L_EMAIL' => $lang['Email'],
'L_PM' => $lang['Private_Message'],
'L_ICQ_NUMBER' => $lang['ICQ'],
'L_YAHOO' => $lang['YIM'],
'L_AIM' => $lang['AIM'],
'L_MESSENGER' => $lang['MSNM'],
'L_WEBSITE' => $lang['Website'],
'L_LOCATION' => $lang['Location'],
'L_OCCUPATION' => $lang['Occupation'],
'L_INTERESTS' => $lang['Interests'],
// Start add - Birthday MOD
'L_BIRTHDAY' => $lang['Birthday'],
// End add - Birthday MOD
'U_SEARCH_USER' => append_sid("search.$phpEx?search_author=" . urlencode($profiledata['username'])),
'S_PROFILE_ACTION' => append_sid("profile.$phpEx"))
);
The time it takes to find the error can be way past the time it takes to upload the original file, or even worst case, re-upload the forum. Don't let it beat you :)
I always rename any phpbb file, "ORIG_thephpbbfilename.php", before altering it. If it stops working, simply delete and set back the original file. Troubleshooting phpbb is not very nice for persons unfamiliar with php.
If it still fails after re-uploading, if its a MOD u installed, re-upload all the files related with the MOD. Otherwise, post it in the phpbb forums. They'd be able to sort ya out!
NEVER, NEVER edit a phpbb file without backing up. I once had to re-install an entire forum *shame*. Was very early though....a couple days after installation. LOL!
Well goodluck!