Jump to content

[SOLVED] Need Fresh pair of Eyes - Should be easy.


Lamez

Recommended Posts

I am sorry if I am wasting a thread on this, but I cannot found how to fix this. I have been lookin at this for a while now, and try to remake it, but still need some help

 

here is the error:

Parse error: syntax error, unexpected T_ELSEIF in /mounted-storage/home48c/sub007/sc33591-LWQU/picks_web/admin_area/usmg/del_us.php on line 26

 

code:

<?php
ob_start();
$path = "../../";
$title = "Update Home";
$rank = "yes";
include ($path."main/include/cons/head.php");
if($session->logged_in){
  if($session->isAdmin()){
    $getlink = $_GET["cmd"];

if ($getlink == "yes") {
    if ($dele !== (md5("yes"))){
header('Location: del_us.php');
}else{
      $results = mysql_query("SELECT * FROM `users`");
        while($row = mysql_fetch_array($results)){
         $user = $row['username'];
     $lvl = $row['userlevel'];
     if ($lvl == ('1')){
      mysql_query("DELETE FROM `users` WHERE `username` = '$user'");
      mysql_query("DELETE FROM `userpoints` WHERE `username` = '$user'");
	  $_SESSION['del_message'] = $user.' has been deleted.';
      header('Location: del_us.php');
     }
       } 
elseif ($getlink == "check") {
   $ans = $_POST['ans'];
   if ($ans == ("yes")){
   header('Location: ?cmd=dele');
   $dele = md5("yes");
   }
   if ($ans == ("no")){
   $_SESSION['del_message'] = $user.' has  not been deleted.';
   header('Location: del_us.php');
   }
}
elseif ($getlink == "ask") {
  if (!isset($_POST['ask'])){
   header('Location: del_us.php');
   exit;
  }
?>
  <form id="form1" name="form1" method="post" action="?cmd=check">
  <table width="100%" border="0">
    <tr>
      <td width="29%">Are you sure you want to delete <?php echo $_POST['user']; ?></td>
      <td width="71%"><label>
        <input type="submit" name="yes" id="ans" value="Yes!" />
        <input type="submit" name="no" id="ans" value="No!" />
      </label></td>
    </tr>
  </table>
</form>
<?php  
}
else {
?>
<p class="header">Delete Users</p>
<p class="maintext">
<?php echo $_SESSION['del_message']; ?>
<br />
<form id="us_lvl" name="us_lvl" method="post" action="?cmd=ask">
  <table width="100%" border="0">
    <tr>
      <td width="7%">User List</td>
      <td width="13%"><label>
        <select name="user" id="user">
<?php
         $q = mysql_query("SELECT * FROM `users`");
	 while($row = mysql_fetch_array($q));
		$usn = $row['username'];
		$lvl = $row['userlevel'];
	 //$user_ is defined in head.php as logged in username.
	     if ($usn !== ($user_)){
		  if ($lvl !== ('9')){
               echo '<option value="'.$usn.'">'.$usn.'</option>';
	     }
	   }
         }
?>
        </select>
      </label></td>
      <td width="14%"><label>
        <input type="submit" name="ask" id="ask" value="Delete" />
      </label></td>
      <td width="66%"><label></label></td>
    </tr>
  </table>
</form>
</p>
<?php
}
  }else{
  header('Location: '.$path.'index.php');
  }
}else{
header('Location: '.$path.'index.php');
}
include ($path."main/include/cons/foot.php");
?>

 

line 26:

elseif ($getlink == "check") {

i think you missed } before

elseif ($getlink == "check") {

 

if ($getlink == "yes") {
if ($dele !== (md5("yes"))){
	header('Location: del_us.php');
}
else{
	$results = mysql_query("SELECT * FROM `users`");
	while($row = mysql_fetch_array($results)){
		$user = $row['username'];
		$lvl = $row['userlevel'];
		if ($lvl == ('1')){
			mysql_query("DELETE FROM `users` WHERE `username` = '$user'");
			mysql_query("DELETE FROM `userpoints` WHERE `username` = '$user'");
			$_SESSION['del_message'] = $user.' has been deleted.';
			header('Location: del_us.php');
		}
	}
}
}

 

i aligned your code  ;)

well If I use your code I get a whole new error:

 

Parse error: syntax error, unexpected '}' in /mounted-storage/home48c/sub007/sc33591-LWQU/picks_web/admin_area/usmg/del_us.php on line 99

 

<?php
ob_start();
$path = "../../";
$title = "Update Home";
$rank = "yes";
include ($path."main/include/cons/head.php");
if($session->logged_in){
  if($session->isAdmin()){
    $getlink = $_GET["cmd"];

if ($getlink == "yes") {
if ($dele !== (md5("yes"))){
	header('Location: del_us.php');
}
else{
	$results = mysql_query("SELECT * FROM `users`");
	while($row = mysql_fetch_array($results)){
		$user = $row['username'];
		$lvl = $row['userlevel'];
		if ($lvl == ('1')){
			mysql_query("DELETE FROM `users` WHERE `username` = '$user'");
			mysql_query("DELETE FROM `userpoints` WHERE `username` = '$user'");
			$_SESSION['del_message'] = $user.' has been deleted.';
			header('Location: del_us.php');
		}
	}
}
}
elseif ($getlink == "check") {
   $ans = $_POST['ans'];
   if ($ans == ("yes")){
   header('Location: ?cmd=dele');
   $dele = md5("yes");
   }
   if ($ans == ("no")){
   $_SESSION['del_message'] = $user.' has  not been deleted.';
   header('Location: del_us.php');
   }
}
elseif ($getlink == "ask") {
  if (!isset($_POST['ask'])){
   header('Location: del_us.php');
   exit;
  }
?>
  <form id="form1" name="form1" method="post" action="?cmd=check">
  <table width="100%" border="0">
    <tr>
      <td width="29%">Are you sure you want to delete <?php echo $_POST['user']; ?></td>
      <td width="71%"><label>
        <input type="submit" name="yes" id="ans" value="Yes!" />
        <input type="submit" name="no" id="ans" value="No!" />
      </label></td>
    </tr>
  </table>
</form>
<?php  
}
else {
?>
<p class="header">Delete Users</p>
<p class="maintext">
<?php echo $_SESSION['del_message']; ?>
<br />
<form id="us_lvl" name="us_lvl" method="post" action="?cmd=ask">
  <table width="100%" border="0">
    <tr>
      <td width="7%">User List</td>
      <td width="13%"><label>
        <select name="user" id="user">
<?php
         $q = mysql_query("SELECT * FROM `users`");
	 while($row = mysql_fetch_array($q));
		$usn = $row['username'];
		$lvl = $row['userlevel'];
	 //$user_ is defined in head.php as logged in username.
	     if ($usn !== ($user_)){
		  if ($lvl !== ('9')){
               echo '<option value="'.$usn.'">'.$usn.'</option>';
	     }
	   }
         }
?>
        </select>
      </label></td>
      <td width="14%"><label>
        <input type="submit" name="ask" id="ask" value="Delete" />
      </label></td>
      <td width="66%"><label></label></td>
    </tr>
  </table>
</form>
</p>
<?php
}
  }else{
  header('Location: '.$path.'index.php');
  }
}else{
header('Location: '.$path.'index.php');
}
include ($path."main/include/cons/foot.php");
?>

 

line 99:

}else{

header('Location: '.$path.'index.php');

}

include ($path."main/include/cons/foot.php");

 

I do not understand why it is doing this.

Well Juan Dela Cruz fixed your first error but then there was another one further down... on line 109 you had to many closing tags } before the last else. then that should fix it

 

<?php
ob_start();
$path = "../../";
$title = "Update Home";
$rank = "yes";
include ($path."main/include/cons/head.php");
if($session->logged_in){
  if($session->isAdmin()){
    $getlink = $_GET["cmd"];

if ($getlink == "yes") {
if ($dele !== (md5("yes"))){
	header('Location: del_us.php');
}
else{
	$results = mysql_query("SELECT * FROM `users`");
	while($row = mysql_fetch_array($results)){
		$user = $row['username'];
		$lvl = $row['userlevel'];
		if ($lvl == ('1')){
			mysql_query("DELETE FROM `users` WHERE `username` = '$user'");
			mysql_query("DELETE FROM `userpoints` WHERE `username` = '$user'");
			$_SESSION['del_message'] = $user.' has been deleted.';
			header('Location: del_us.php');
		}
	}
}
}
elseif ($getlink == "check") {
   $ans = $_POST['ans'];
   if ($ans == ("yes")){
   header('Location: ?cmd=dele');
   $dele = md5("yes");
   }
   if ($ans == ("no")){
   $_SESSION['del_message'] = $user.' has  not been deleted.';
   header('Location: del_us.php');
   }
}
elseif ($getlink == "ask") {
  if (!isset($_POST['ask'])){
   header('Location: del_us.php');
   exit;
  }
?>
  <form id="form1" name="form1" method="post" action="">
  <table width="100%" border="0">
    <tr>
      <td width="29%">Are you sure you want to delete <?php echo $_POST['user']; ?></td>
      <td width="71%"><label>
        <input type="submit" name="yes" id="ans" value="Yes!" />
        <input type="submit" name="no" id="ans" value="No!" />
      </label></td>
    </tr>
  </table>
</form>
<?php  
}
else {
?>
<p class="header">Delete Users</p>
<p class="maintext">
<?php echo $_SESSION['del_message']; ?>
<br />
<form id="us_lvl" name="us_lvl" method="post" action="">
  <table width="100%" border="0">
    <tr>
      <td width="7%">User List</td>
      <td width="13%"><label>
        <select name="user" id="user">
<?php
         $q = mysql_query("SELECT * FROM `users`");
	 while($row = mysql_fetch_array($q));
		$usn = $row['username'];
		$lvl = $row['userlevel'];
	 //$user_ is defined in head.php as logged in username.
	     if ($usn !== ($user_)){
		  if ($lvl !== ('9')){
               echo '<option value="'.$usn.'">'.$usn.'</option>';
	     }
	   }
         }
?>
        </select>
      </label></td>
      <td width="14%"><label>
        <input type="submit" name="ask" id="ask" value="Delete" />
      </label></td>
      <td width="66%"><label></label></td>
    </tr>
  </table>
</form>
</p>
<?php
}
  }else{
  header('Location: '.$path.'index.php');
  }
else{
header('Location: '.$path.'index.php');
}
include ($path."main/include/cons/foot.php");
?>

Once you removed the } in threw another error unexpected else

 

try this

 

<?php
ob_start();
$path = "../../";
$title = "Update Home";
$rank = "yes";
include ($path."main/include/cons/head.php");
if($session->logged_in){
  if($session->isAdmin()){
    $getlink = $_GET["cmd"];

if ($getlink == "yes") {
if ($dele !== (md5("yes"))){
	header('Location: del_us.php');
}
else{
	$results = mysql_query("SELECT * FROM `users`");
	while($row = mysql_fetch_array($results)){
		$user = $row['username'];
		$lvl = $row['userlevel'];
		if ($lvl == ('1')){
			mysql_query("DELETE FROM `users` WHERE `username` = '$user'");
			mysql_query("DELETE FROM `userpoints` WHERE `username` = '$user'");
			$_SESSION['del_message'] = $user.' has been deleted.';
			header('Location: del_us.php');
		}
	}
}
}
elseif ($getlink == "check") {
   $ans = $_POST['ans'];
   if ($ans == ("yes")){
   header('Location: ?cmd=dele');
   $dele = md5("yes");
   }
   if ($ans == ("no")){
   $_SESSION['del_message'] = $user.' has  not been deleted.';
   header('Location: del_us.php');
   }
}
elseif ($getlink == "ask") {
  if (!isset($_POST['ask'])){
   header('Location: del_us.php');
   exit;
  }
?>
  <form id="form1" name="form1" method="post" action="?cmd=check">
  <table width="100%" border="0">
    <tr>
      <td width="29%">Are you sure you want to delete <?php echo $_POST['user']; ?></td>
      <td width="71%"><label>
        <input type="submit" name="yes" id="ans" value="Yes!" />
        <input type="submit" name="no" id="ans" value="No!" />
      </label></td>
    </tr>
  </table>
</form>
<?php  
}
else {
?>
<p class="header">Delete Users</p>
<p class="maintext">
<?php echo $_SESSION['del_message']; ?>
<br />
<form id="us_lvl" name="us_lvl" method="post" action="?cmd=ask">
  <table width="100%" border="0">
    <tr>
      <td width="7%">User List</td>
      <td width="13%"><label>
        <select name="user" id="user">
<?php
         $q = mysql_query("SELECT * FROM `users`");
	 while($row = mysql_fetch_array($q));
		$usn = $row['username'];
		$lvl = $row['userlevel'];
	 //$user_ is defined in head.php as logged in username.
	     if ($usn !== ($user_)){
		  if ($lvl !== ('9')){
               echo '<option value="'.$usn.'">'.$usn.'</option>';
	     }
	   }
         }
?>
        </select>
      </label></td>
      <td width="14%"><label>
        <input type="submit" name="ask" id="ask" value="Delete" />
      </label></td>
      <td width="66%"><label></label></td>
    </tr>
  </table>
</form>
</p>
<?php
}
  }else{
  header('Location: '.$path.'index.php');
  
}
include ($path."main/include/cons/foot.php");
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.