我有一個功能的文件,當我將一個函數添加它,無論身在何處,它說,那裏有文件就行意外結束51意外結束時,它不會結束
這裏的我的代碼。
<?php
function newcat() {
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if (!isset($_SESSION['user_id'])) {
echo '<p class="login">Please <a href="login.php">log in</a> to access this page.</p>';
exit();
}
else {
echo('<p class="login">You are logged in as ' . $_SESSION['username'] . '. <a href="logout.php">Log out</a>.</p>');
}
// Connect to the database
if (isset($_POST['submit'])) {
// Grab the profile data from the POST
$catt = mysqli_real_escape_string($dbc, strip_tags(trim($_POST['catt']))); $desc = mysqli_real_escape_string($dbc, strip_tags(trim($_POST['desc'])));
// Update the post data in the database
if (!empty($catt)) {
strip_tags($post1);
$query = "INSERT INTO categories (`name`, `desc`) VALUES ('$catt', '$desc')";
mysqli_query($dbc, $query);
// Confirm success with the user
echo '<p>Your category has been successfully added. Would you like to go back to the <a href="acp.php">Admin Panel</a>?</p>';
echo $catt;
mysqli_close($dbc);
exit();
}
else {
echo '<p class="error">You must enter information into all of the fields.</p>';
}
} // End of check for form submission
if(!verify("O")){exit();}
echo'<form enctype="multipart/form-data" method="post" action="acp.php?action=vc">
<fieldset>
<legend>Create Category:</legend>
<label type="hidden" for="catt">Category name:</label><br />
<input type="text" name="catt"><br /><br /> <label type="hidden" for="desc">Description</label><br /> <textarea rows="4" name="desc" id="desc" cols="100"></textarea>
</fieldset>
<input type="submit" value="Save Category" name="submit" />
</form>';
echo '<table class"admin" border=1>';
echo '<tr><th>Categories</th></tr>';
$query = "SELECT * FROM categories ORDER BY cat_id ASC";
$data = mysqli_query($dbc, $query);
$gender = $row['gender'];
while ($row = mysqli_fetch_array($data)) {
echo '<tr>';
echo '<td>'.$row['name'].'</td></tr>';
}
mysqli_close($dbc);
echo'</table>';
echo'</div>';
}
function verify($permissionName){
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$query = "SELECT permissions FROM user WHERE user_id = '" . $_SESSION['user_id'] . "'";
$data = mysqli_query($dbc, $query);
$row = mysqli_fetch_array($data);
if($row['permissions'] === $permissionName){
return true;
} else {
return false;
}
}
function group($groupName){
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$query = "SELECT usergroup FROM user WHERE user_id = '" . $_SESSION['user_id'] . "'";
$data = mysqli_query($dbc, $query);
$row = mysqli_fetch_array($data);
if($row['usergroup'] === $groupName){
return true;
} else {
return false;
}
}
function gperms($groupPerm, $user) {
$query = "SELECT * FROM groups WHERE group_id = $group";
$data = mysqli_query($dbc, $query);
$row = mysqli_fetch_array($data);
$groupname = $row['groupname'];
$users = explode(",", $row['username']);
foreach($users as $k => $member){
list($username, $rank) = explode(":", $member);
}
$query = "SELECT usergroup FROM user WHERE user_id = '" . $_SESSION['user_id'] . "'";
$data = mysqli_query($dbc, $query);
$row = mysqli_fetch_array($data);
if(($row['username'] === $user) && ($rank === $groupPerm)){
return true;
} else {
return false;
}
}
?>
我需要知道是什麼原因造成這一點,因爲上線51它說mysqli_query($dbc, $query);
而不應結尾的文件。
此外,我可以在不同的文件中,它的工作原理,但不是在這個文件。
您是否必須發佈*全部*您的代碼? –
如果您正確縮進所有代碼,找到缺少的分號將會很簡單。 –
@JohnConde其實,是的,並且沒有缺少分號 – user3534341