Hello all,
Today I received this as my error:
Parse error: syntax error, unexpected T_STRING in /home/a8712935/public_html/admin_members.php on line 60
I've looked all over the internet but I can't find a solution to my problem. There is nothing wrong with that line, but I think it is a problem with quotations or something. Another set of eyes to find this problem would be helpful. Here's the code:
<?php
session_start();
// If the session vars aren't set, try to set them with a cookie
if (!isset($_SESSION['user_id'])) {
if (isset($_COOKIE['user_id']) && isset($_COOKIE['username'])) {
$_SESSION['user_id'] = $_COOKIE['user_id'];
$_SESSION['username'] = $_COOKIE['username'];
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Wow What Is This - Admin Home</title>
</head>
<body>
<h3>Wow What Is This - Admin Home</h3>
<?php
require_once("connectvars.php");
if(!isset($_SESSION['user_id'])){
echo '<p>It appears as if you are not logged in. Please <a href = "login.php">log in</a> or <a href = "signup.php">sign up</a> to continue</p>';
exit();
}
else{
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$query = "SELECT user_prvg FROM wwit_user WHERE user_id = '" . $_SESSION['user_id'] . "'";
$data = mysqli_query($dbc, $query);
$row = mysqli_fetch_array($data);
if($row['user_prvg'] != 1)
{
echo '<p>It appears that you are do not have the privileges to access this page.</p><br />';
echo '<p>Click <a href = "index.php">here</a> to return to the home page</p>';
exit();
}
else
{
echo '<p>You are an admin logged in as ' . $_SESSION['username'] . '.</p><br />';
}
$query2 = "SELECT * FROM wwit_user ORDER BY join_date DESC, username DESC";
$member_data = mysqli_query($dbc, $query2);
$member_row = mysqli_fetch_array($member_data);
echo '<h4>Current Members</h4>';
echo '<form action = "admin_members.php" method = "post">';
while ($member_row){
echo '<input type="checkbox" name = "member[]" value = "' . $member_row['user_id'] . '" />'. $member_row['username'].'<br />';
}
echo '<input type = "submit" name = "formSubmit" value = "Delete Users" />';
echo '</form>';
if(isset($_POST['formSubmit'])){
int counter = 0;
$member_array = $_POST['member'];
while($member_array){
$query3 = "DELETE FROM wwit_user WHERE user_id = '" . $member_array[i] ."'";
bool $success = mysqli_query($dbc, $query3);
counter++;
}
if($success== true)
{
echo 'You successfully deleted ' . (counter+1) . ' user(s) from the database';
echo 'Return to the <a href = "admin_home">Admin Home</a>';
}
}
}
?>
</body>
</html>