Jump to content

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");
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.