问题描述:

trying to make it check first if the current account is actually the one that it's trying to delete.

keep getting error

Parse error: syntax error, unexpected T_BOOLEAN_AND, expecting ',' or ') on line 12.

if (isset($_SESSION['id'] && $_SESSION['id'] == $_GET['id'])) { --line 12--

if (isset($_GET['BookID']) && is_numeric($_GET['BookID']))

{

// get id value

$BookID = $_GET['BookID'];

// delete the entry

$sql = "DELETE FROM `tbl_booking` WHERE `BookID`={$BookID}";

$result = mysqli_query($con, $sql);

echo "Your booking has been cancelled.";

}

else

// if id isn't set, or isn't valid, redirect back to view page

{

echo "doesn't work";

header('location: dashboard.php');

}

}

网友答案:

You're just missing a ) and there's an extra at the end:

if (isset($_SESSION['id']) && $_SESSION['id'] == $_GET['id']) { 
                    -----^                one less here-----^

Also, you're going to need single quotes around this parameter, unless it will always, always be an integer:

$sql = "DELETE FROM `tbl_booking` WHERE `BookID`='{$BookID}'";
相关阅读:
Top