Parse error: syntax error, unexpected T_ELSE in /home3/mafiasec/public_html/logincheck.php on line 311 -


here's code, it's irritating can't find problem.. have been looking past 2 days , can't work out myself, relatively new coding please explain going on because won't understand saying. please give me hand here - here's code.

    <?php session_start(); include_once("includes/db_connect.php"); if (isset($_session['real_name'])){ include "mainmenu.php"; die("-"); exit(); }    error_reporting(0);   //this of course tells website follows $realip=$_server['remote_addr'];      if ($_post['submit'] && mysql_real_escape_string($_post['username'])){    function change($msg){ $post = $msg; $post = str_replace(" ", "", $post);  return $post; }  $username = $_post['username'];  $password = $_post['password']; $password = mysql_real_escape_string(strip_tags($password)); $ip = $_server['remote_addr'];    $date = gmdate('y-m-d h:i:s');    $tquery = "select nextlogin users username='$username'";  $tresult = mysql_query($tquery) or die(mysql_error()); $trow = mysql_fetch_array($tresult);   if((time() < $trow['nextlogin']) ) {  $waittime=$trow['nextlogin'] - time(); die("this user has allready tried login in past 30 seconds! please wait $waittime seconds before can login!");  }    $result = mysql_query("select * loginip") or die("hack protection error please contact admin@mafiasecrets.com , tell him this!"); // keeps getting next row until there no more     while($row = mysql_fetch_array( $result )) {  $id = $row['id']; $timeleft = $row['time'] - time();   if ($timeleft <0){mysql_query("delete loginip id='$id'");}  }// while loop    $select = mysql_query("select * loginip ip='$realip'"); $num = mysql_num_rows($select);  if($num>"0"){ die("your ip has allready tried login in past 30 seconds, please wait $timeleft seconds before can login again!"); }    ///check info $sql = mysql_query("select * users username='$username' , password='$password' limit 1");  $login_check = mysql_num_rows($sql);  $inf = mysql_fetch_object($sql);   if ($login_check > "0"){           session_register('username');          $_session['real_name'] = $username;     //this of course tells website follows $realip=$_server['remote_addr'];      $time2 = time();               $timestamp = time()+60;    $sql = "update users set nextlogin='".strtotime ("+30 seconds")."' username='".mysql_real_escape_string($username)."'";  mysql_query($sql);   $sql = "insert loginip set id = '', ip = '$realip', time = '".strtotime ("+20 seconds")."'"; $res = mysql_query($sql); mysql_query("update lastloginname set username='$username' ip='$realip'");  mysql_query("update users set online='online', onlinetime2='$time2' username='$username'"); mysql_query("update users set apperoffline='1' username='$username'")or die("error aper oflin");   $time1=time()+500;  mysql_query("insert `loggedin` (`id`, `ip`, `username`, `time`) values ('', '$realip', '$username', '$time1')");    $sql = mysql_query("select * facebookshare username='$username'");  $fb_check = mysql_num_rows($sql);    if ($fb_check == "0"){  $timef = gmdate('y-m-d h:i:s');   ?>    <?php  mysql_query("insert `facebookshare` (`id`, `username`, `time`) values ('', '$username', '$timef')");  }//not shared    ?><?php $sql="select * users username='$username' limit 1"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ // start looping table row    $rank = mysql_real_escape_string(strip_tags($rows['rank'])); $health = mysql_real_escape_string(strip_tags($rows['health'])); $country = mysql_real_escape_string(strip_tags($rows['country'])); $rankpoints = mysql_real_escape_string(strip_tags($rows['rankpoints'])); $rankbar = mysql_real_escape_string(strip_tags($rows['rankbar'])); $firstlogin = mysql_real_escape_string(strip_tags($rows['firstlogin']));  } ?> <? if($_post['a']){ mysql_query("update users set `firstlogin`=`firstlogin`+'1' username='$username'"); echo "<meta http-equiv='refresh' content='1;url=veri.php'>"; } ?> <style type="text/css"> <!-- .textbox {background-color: 222222; border-bottom: 1px solid #626262; border-left: 1px solid #040404; border-right: 1px solid #626262; border-top: 1px solid #040404; color: white; font-family: verdana; font-size: 18px;} --> </style> <body bgcolor="#222222">    <meta http-equiv="refresh" content="4; url=play.php">  <table cellpadding="0" width="100%" height="100%">  <td width="100%" height = "100%"><center>  <font color="white" face="verdana" size="3">welcome: </font><b><font color=khaki size=3 face=verdana><? echo $username ?></font></b><br> <table width=300 cellpadding=0 cellspacing=0 align=center>   <tr>     <td height=5></td>   </tr>   <tr>     <td height=1 bgcolor=#444444></td>   </tr>   <tr>     <td height=5></td>   </tr> </table>  <?php  $rank_1 = "hobo"; $rank_2 = "citizen"; $rank_3 = "vandal"; $rank_4 = "thug"; $rank_5 = "respected thug"; $rank_6 = "mobster"; $rank_7 = "respected mobster"; $rank_8 = "assassin"; $rank_9 = "respected assassin"; $rank_10 = "mafioso"; $rank_11 = "respected mafioso"; $rank_12 = "underboss"; $rank_13 = "respected underboss"; $rank_14 = "boss"; $rank_15 = "respected boss"; $rank_16 = "godfather"; $rank_17 = "respected godfather"; $rank_18 = "gangster"; $rank_19 = "immaculate gangster";    $rank_2_exp = "50"; $rank_3_exp = "120"; $rank_4_exp = "350"; $rank_5_exp = "1100"; $rank_6_exp = "3200"; $rank_7_exp = "6100"; $rank_8_exp = "11300"; $rank_9_exp = "15000"; $rank_10_exp = "21000"; $rank_11_exp = "30000"; $rank_12_exp = "41000"; $rank_13_exp = "52000"; $rank_14_exp = "66500"; $rank_15_exp = "82500"; $rank_16_exp = "98000"; $rank_17_exp = "128000"; $rank_18_exp = "147000"; $rank_19_exp = "170000";     ?> <?php $newmail = mysql_query("select * messages t='$username' , r='0'"); $notoriouslegendskk = mysql_num_rows($newmail);?>  <?    if ($rankbar>=1){    if ($rankpoints > "$rank_19_exp"){  $nextrank = 0; }else{   if ($rankpoints < "$rank_2_exp"){ $amount="$rank_2_exp"; $check="0";} elseif ($rankpoints < "$rank_3_exp"){ $amount="$rank_3_exp"; $check="$rank_2_exp";} elseif ($rankpoints < "$rank_4_exp"){ $amount="$rank_4_exp"; $check="$rank_3_exp";} elseif ($rankpoints < "$rank_5_exp"){ $amount="$rank_5_exp"; $check="$rank_4_exp";} elseif ($rankpoints < "$rank_6_exp"){ $amount="$rank_6_exp"; $check="$rank_5_exp";} elseif ($rankpoints < "$rank_7_exp"){ $amount="$rank_7_exp"; $check="$rank_6_exp";} elseif ($rankpoints < "$rank_8_exp"){ $amount="$rank_8_exp";  $check="$rank_7_exp";} elseif ($rankpoints < "$rank_9_exp"){ $amount="$rank_9_exp"; $check="$rank_8_exp";} elseif ($rankpoints < "$rank_10_exp"){ $amount="$rank_10_exp"; $check="$rank_9_exp";} elseif ($rankpoints < "$rank_11_exp"){ $amount="$rank_11_exp"; $check="$rank_10_exp";} elseif ($rankpoints < "$rank_12_exp"){ $amount="$rank_12_exp"; $check="$rank_11_exp";} elseif ($rankpoints < "$rank_13_exp"){ $amount="$rank_13_exp"; $check="$rank_12_exp";} elseif ($rankpoints < "$rank_14_exp"){ $amount="$rank_14_exp"; $check="$rank_13_exp";} elseif ($rankpoints < "$rank_15_exp"){ $amount="$rank_15_exp"; $check="$rank_14_exp";} elseif ($rankpoints < "$rank_16_exp"){ $amount="$rank_16_exp"; $check="$rank_15_exp";} elseif ($rankpoints < "$rank_17_exp"){ $amount="$rank_17_exp"; $check="$rank_16_exp";} elseif ($rankpoints < "$rank_18_exp"){ $amount="$rank_18_exp"; $check="$rank_17_exp";} elseif ($rankpoints < "$rank_19_exp"){ $amount="$rank_19_exp"; $check="$rank_18_exp";}  /// total rankpoints - rankpoints required current rank / rank points needed next rank * 100  $end = $amount - $check;    $percent = $rankpoints - $check;    $percent = $percent / $end; $add = $percent * 100;  if($rankbar==2){ $nextrank = sprintf ("%0.1f",$add); }else{ $nextrank = round($add); }  }//not undercover gangster  ?> <font color=white face=verdana size=2>you have <b style=color:khaki;><?php echo $notoriouslegendskk ?></b> new messages!</font><br> <table width=300 cellpadding=0 cellspacing=0 align=center>   <tr>     <td height=5></td>   </tr>   <tr>     <td height=1 bgcolor=#444444></td>   </tr>   <tr>     <td height=5></td>   </tr> </table> <font color=silver face=verdana size=1>rank: </font><font color=white face=verdana size=1><?php echo $rank ?></font><font color=silver face=verdana size=1> | </font> <font color=silver face=verdana size=1>rank up: </font><font color=white face=verdana size=1><?php echo $nextrank ?>%</font><font color=silver face=verdana size=1> | </font> <font color=silver face=verdana size=1>health: </font><font color=white face=verdana size=1><?php echo $health ?>%</font><font color=silver face=verdana size=1> | </font> <font color=silver face=verdana size=1>location: </font><font color=white face=verdana size=1><?php echo $country ?></font><br> </center>  </td>  </table>  </body> <?php } ?> <?php    } else {   $sql = "update users set nextlogin='".strtotime ("+20 seconds")."' username='".mysql_real_escape_string($username)."'";  mysql_query($sql);  $failtime = date('d-m-y h:i:s', strtotime('+5 hours'));  mysql_query("insert loginfails set id = '', ip = '$realip', time = '$failtime', username = '$username', password = '$password'"); $sql = "insert loginip set id = '', ip = '$realip', time = '".strtotime ("+30 seconds")."'"; $res = mysql_query($sql);      echo"<b>invalid username/password, please go , <a href=index.php>try again!</a></b>";  }else{ die("you did not attempt login, <a href=index.php>click</a> here go login page!"); } ?> 

you have else statement on line 298. cannot have else following that.

i think might because missing matching } code @ line 22 (the if() statement not have closing }). guessing else statement should match if(), in case need add 1 } before else on line 311.

also, agree others need clean code , use proper spacing. makes debugging easier.

edit: here's relevant part fixed code:

</body> <?php    } ?> <?php          } else {            $sql = "update users set nextlogin='".strtotime ("+20 seconds")."' username='".mysql_real_escape_string($username)."'";          mysql_query($sql);           $failtime = date('d-m-y h:i:s', strtotime('+5 hours'));           mysql_query("insert loginfails set id = '', ip = '$realip', time = '$failtime', username = '$username', password = '$password'");          $sql = "insert loginip set id = '', ip = '$realip', time = '".strtotime ("+30 seconds")."'";          $res = mysql_query($sql);           echo"<b>invalid username/password, please go , <a href=index.php>try again!</a></b>";         }      // here } need add      } else {       die("you did not attempt login, <a href=index.php>click</a> here go login page!");    } ?> 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -