khile Posted October 19, 2010 Share Posted October 19, 2010 im having a bit of problem with a section of code im tryingto help a friend code a app but its not working keep getting t_else error <?php require FORUM_ROOT.'footer.php'; } else if ($action == 'delete_avatar') // Shows this line has error { if ($forum_user['id'] != $id && $forum_user['g_id'] > USER_MOD) xBB_Message($lang_common['No permission']); xBB_Confirm_Referrer('profile.php'); @unlink($configuration['o_avatars_dir'].'/'.$id.'.jpg'); @unlink($configuration['o_avatars_dir'].'/'.$id.'.png'); @unlink($configuration['o_avatars_dir'].'/'.$id.'.gif'); $db->query('UPDATE '.$db->prefix.'users SET use_avatar=0 WHERE id='.$id) or xBB_Error('Unable to update avatar state', __FILE__, __LINE__, $db->error()); xBB_Redirect('profile.php?section=personality&id='.$id, $lang_profile['Avatar deleted redirect']); } Quote Link to comment https://forums.phpfreaks.com/topic/216266-t_else-error/ Share on other sites More sharing options...
Mchl Posted October 19, 2010 Share Posted October 19, 2010 It's impossible to have 'else' without having 'if' first. Quote Link to comment https://forums.phpfreaks.com/topic/216266-t_else-error/#findComment-1123891 Share on other sites More sharing options...
khile Posted October 19, 2010 Author Share Posted October 19, 2010 Parse error: syntax error, unexpected $end online 1651 <?php require FORUM_ROOT.'footer.php'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/216266-t_else-error/#findComment-1123893 Share on other sites More sharing options...
Vettel Posted October 19, 2010 Share Posted October 19, 2010 Try this: require FORUM_ROOT.'footer.php'; if($action == 'delete_avatar'){ if($forum_user['id'] != $id && $forum_user['g_id'] > USER_MOD){ xBB_Message($lang_common['No permission']); xBB_Confirm_Referrer('profile.php'); @unlink($configuration['o_avatars_dir'].'/'.$id.'.jpg'); @unlink($configuration['o_avatars_dir'].'/'.$id.'.png'); @unlink($configuration['o_avatars_dir'].'/'.$id.'.gif'); $db->query('UPDATE '.$db->prefix.'users SET use_avatar=0 WHERE id='.$id) or xBB_Error('Unable to update avatar state', __FILE__, __LINE__, $db->error()); xBB_Redirect('profile.php?section=personality&id='.$id, $lang_profile['Avatar deleted redirect']); } } Quote Link to comment https://forums.phpfreaks.com/topic/216266-t_else-error/#findComment-1123894 Share on other sites More sharing options...
Mchl Posted October 19, 2010 Share Posted October 19, 2010 Perhaps you should try learning some basic syntax? Quote Link to comment https://forums.phpfreaks.com/topic/216266-t_else-error/#findComment-1123898 Share on other sites More sharing options...
khile Posted October 19, 2010 Author Share Posted October 19, 2010 im not saying i know alot just trying to help a friend i have changed code and get: Parse error: syntax error, unexpected $end in C:\xampp\htdocs\2\profile.php on line 1649 and that line equals <?php require FORUM_ROOT.'footer.php'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/216266-t_else-error/#findComment-1123934 Share on other sites More sharing options...
Pikachu2000 Posted October 19, 2010 Share Posted October 19, 2010 That usually indicates a curly brace left open. Quote Link to comment https://forums.phpfreaks.com/topic/216266-t_else-error/#findComment-1123935 Share on other sites More sharing options...
khile Posted October 19, 2010 Author Share Posted October 19, 2010 <?php } } ?> </form> </div> <?php } ?> <div class="clearer"></div> </div> <?php require FORUM_ROOT.'footer.php'; } } ?> thats the code and says errors on line 1651, the very last line i found and closed the open bracket ps: sorry to be a pain Quote Link to comment https://forums.phpfreaks.com/topic/216266-t_else-error/#findComment-1123944 Share on other sites More sharing options...
Vettel Posted October 19, 2010 Share Posted October 19, 2010 khile could you post your entire code please? Quote Link to comment https://forums.phpfreaks.com/topic/216266-t_else-error/#findComment-1123946 Share on other sites More sharing options...
Pikachu2000 Posted October 19, 2010 Share Posted October 19, 2010 For the error to point to the last line is normal. After all, the php interpreter has no idea where you intended to put the closing brace . . . Quote Link to comment https://forums.phpfreaks.com/topic/216266-t_else-error/#findComment-1123948 Share on other sites More sharing options...
khile Posted October 19, 2010 Author Share Posted October 19, 2010 says code is too long more that 40000 charactors ill try and split Quote Link to comment https://forums.phpfreaks.com/topic/216266-t_else-error/#findComment-1123963 Share on other sites More sharing options...
khile Posted October 19, 2010 Author Share Posted October 19, 2010 i have attached file [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/216266-t_else-error/#findComment-1123965 Share on other sites More sharing options...
BlueSkyIS Posted October 19, 2010 Share Posted October 19, 2010 profile.php compiles here. that makes me suspect the problem is in an included file. Quote Link to comment https://forums.phpfreaks.com/topic/216266-t_else-error/#findComment-1123975 Share on other sites More sharing options...
khile Posted October 24, 2010 Author Share Posted October 24, 2010 i got profile php working but im trying to make my code php5 compliant $group_opt = ereg_replace($group.'"', $group.'" selected',$group_opt); but get error Deprecated: Function ereg_replace() is deprecated i found it need to be replaced with preg_replace but that gives a delimiter error thanks Quote Link to comment https://forums.phpfreaks.com/topic/216266-t_else-error/#findComment-1125884 Share on other sites More sharing options...
Mchl Posted October 24, 2010 Share Posted October 24, 2010 http://www.php.net/manual/en/intro.pcre.php The expression must be enclosed in the delimiters, a forward slash (/), for example. Delimiters can be any non-alphanumeric, non-whitespace ASCII character except the backslash (\) and the null byte. If the delimiter character has to be used in the expression itself, it needs to be escaped by backslash. Since PHP 4.0.4, you can also use Perl-style (), {}, [], and <> matching delimiters. Quote Link to comment https://forums.phpfreaks.com/topic/216266-t_else-error/#findComment-1125923 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.