andrew89898 Posted December 5, 2010 Share Posted December 5, 2010 Hello, I have an error when I try to php a file the error is : Parse error: syntax error, unexpected T_PUBLIC in ... on line 959 That part looks like this: public function makeLoginKey($username){ $username = strtoupper($username); $len = strlen($username); for($i = 0; $i < $len; $i++){ if($i %2 == 0){ $username{$i} = strtolower($username{$i}); } } $hash = $this->encryptPassword(base64_encode($username)); $key = substr(strtolower($hash) . strtoupper($hash), 15 - $len, 40 - $len); return strtolower($key); } Thanks for help and line 959 is the first line (public function makeloginkey..) Quote Link to comment https://forums.phpfreaks.com/topic/220751-php-parse-error/ Share on other sites More sharing options...
Lautarox Posted December 5, 2010 Share Posted December 5, 2010 Are you declaring that function in a class? Quote Link to comment https://forums.phpfreaks.com/topic/220751-php-parse-error/#findComment-1143297 Share on other sites More sharing options...
andrew89898 Posted December 5, 2010 Author Share Posted December 5, 2010 Hello, I have just fixed that error. Now I have a new error , Parse error: syntax error, unexpected T_IF, expecting T_FUNCTION in ... on line 1230 The lines look close to 1230 look like this: 1230:if(defined("usekey")){function key_exists($a, $b){ 1231return array_key_exists($a, $b); 1232}} Thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/220751-php-parse-error/#findComment-1143319 Share on other sites More sharing options...
BlueSkyIS Posted December 5, 2010 Share Posted December 5, 2010 parser is expecting something on line 1230, which means the error is probably before that line. we need more code. Quote Link to comment https://forums.phpfreaks.com/topic/220751-php-parse-error/#findComment-1143347 Share on other sites More sharing options...
andrew89898 Posted December 6, 2010 Author Share Posted December 6, 2010 function removeClientBySock($socket){ //debug_print_backtrace(); foreach ($this->clients as $key => &$c){ if($c->sock === $socket){ $this->removeClient($key); return 0; } } return -1; } } if(defined("usekey")){function key_exists($a, $b){ return array_key_exists($a, $b); }} Thats the code before it, Thanks for help. Quote Link to comment https://forums.phpfreaks.com/topic/220751-php-parse-error/#findComment-1143601 Share on other sites More sharing options...
devilinc Posted December 6, 2010 Share Posted December 6, 2010 that's just bad curly braces...check for that extra curly brace which is closed before the if......remove it.... Quote Link to comment https://forums.phpfreaks.com/topic/220751-php-parse-error/#findComment-1143653 Share on other sites More sharing options...
andrew89898 Posted December 7, 2010 Author Share Posted December 7, 2010 Fixed that error , now I believe this is the last error. Parse error: syntax error, unexpected $end in ...php on line 1273 The lines look like this: myErrorHandler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/220751-php-parse-error/#findComment-1144009 Share on other sites More sharing options...
shlumph Posted December 7, 2010 Share Posted December 7, 2010 The lines look like this: myErrorHandler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']); } } ?> From the code you've pasted, we can only tell you that you've closed two brackets without opening two brackets. Quote Link to comment https://forums.phpfreaks.com/topic/220751-php-parse-error/#findComment-1144026 Share on other sites More sharing options...
andrew89898 Posted December 7, 2010 Author Share Posted December 7, 2010 Sorry ^^ heres the code of that function, There is too starting brackets. function fatalErrorShutdownHandler() {(here) $last_error = error_get_last(); if ($last_error['type'] === E_ERROR) {(here) // fatal error myErrorHandler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']); } } ?> The "(here" isnt in the code its just showing that there is two brackets. Quote Link to comment https://forums.phpfreaks.com/topic/220751-php-parse-error/#findComment-1144054 Share on other sites More sharing options...
andrew89898 Posted December 9, 2010 Author Share Posted December 9, 2010 STILL UNSOLVED NEED HELP FOR ERROR I JUST POSTED (THE LAST ONE) THANK YOU , sorry for shouting but this text needs to be read ^^ Quote Link to comment https://forums.phpfreaks.com/topic/220751-php-parse-error/#findComment-1144995 Share on other sites More sharing options...
shlumph Posted December 9, 2010 Share Posted December 9, 2010 It's a syntax error. You're more than likely missing an opening or closing bracket/quote/param somewhere in that humongous 1273+ line file. I'd say post it the entire file, but almost no one here is going to go through 1273+ lines of code to find a single syntax error, lol. In your favorite PHP editor, find out if you're opening something you're not closing. Quote Link to comment https://forums.phpfreaks.com/topic/220751-php-parse-error/#findComment-1145003 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.