0

我不断收到此错误:

Commands out of sync; you can't run this command now

我不知道为什么会发生这种情况,以前的问题都没有帮助。

这是我的代码:

用户.php

public static function GetUserFullName($username){
    if(Utilities::IsValid($username)){
        $username = Utilities::SafeString($username);

        Database::OpenConnection();
        $query = Database::$databaseConnection->prepare("SELECT Name FROM user WHERE Username = ?") or die(Database::$databaseConnection->error);

        $query->bind_param("s", $username);
        $result = $query->execute();

        Database::CloseConnection();
        if($result){

            $query->bind_result($name);
            $query->fetch();
            $query->close();
            return $name;
        }
    }else return -1;
}

技能.php

public static function UpdateSkills($id, $skill, $action){
    if(Utilities::IsValid($id) && Utilities::IsValid($skill) && Utilities::IsValid($action)){
        $id = Utilities::SafeString($id);
        $skill = Utilities::SafeString($skill);
        $action = Utilities::SafeString($action);
        Database::OpenConnection();

        if($action == 'i'){
            $skill = str_replace(" ", "", $skill);
            $db = Database::$databaseConnection;
            $skills = explode(",", $skill);
            $query = "";
            foreach ($skills as $s){
                $query .= "INSERT INTO skill (User_ID,Skill) VALUES({$id},'{$s}');";
            }
            $result = $db->multi_query($query);
            echo $db->error;
            Database::CloseConnection();

            if($result) return 1;
            else return -1;
        }else if($action == 'd'){
            $query = Database::$databaseConnection->prepare("DELETE FROM Skill WHERE Skill = ? AND User_ID = ?");
            $query->bind_param("si", $skill,$id);
            $result = $query->execute();
            Database::CloseConnection();
            if($result && $query->num_rows >0) return 1;
            else return -1;
        }
    }
    return -1;
}

头文件.php

<?php
require_once 'Classes/UserLogin.php';
require_once 'Classes/User.php';
$user_fullname = User::GetUserFullName($_SESSION["username"]);
?>
<header>
    <div class="welcome_area">
        <p>
            Welcome, <b><a href="profile.php" style="text-decoration: underline !important;"><?php echo $user_fullname; ?></a> </b>

        </p>
    </div>
    <div class="menu">
        <nav>
            <ul>
                <li><a href="profile.php">My Profile</a>
                    <ul>

                        <li><div><a href="#">My Questions</a></div>
                        </li>                       
                        <li><div><a href="#">Settings</a></div>
                        </li>
                        <li style="margin-bottom: 5px;"><div><a href="logout.php">Logout</a></div>
                        </li>
                    </ul>
                </li>
                <li><a href="inbox.php">Inbox</a>
                </li>
                <li><a href="#">Notifications</a>
                </li>
            </ul>
        </nav>
    </div>
</header>
<section id="container">
    <br />
    <div id="logo"></div>
    <div id="content">

配置文件.php

<?php
require_once "Classes/User.php";
require_once "Classes/Skill.php";
require_once "Classes/UserLogin.php";
if(!UserLogin::IsLoggedIn("username")) header("location: login.php");
$user_details = User::GetUserDetails($_SESSION["username"]);
echo Skill::UpdateSkills(11, "programmer,designer", "i");
?>
<!DOCTYPE html>
<html>

<head>
<title>Help Exchange</title>
<link rel="stylesheet" href="css/base.css" />
<link rel="stylesheet" href="css/profile.css" />
<link rel="stylesheet" href="css/user.css" />
<link rel="stylesheet" href="css/widgets.css" />

<script src="js/jquery.min.js"></script>
<script src="js/profile.js"></script>

</head>

<body>
    <script>
        var user_details = eval(<?php echo $user_details; ?>);
        var about = user_details.About;
    </script>
    <?php require_once 'admin/header.php';?>

请帮我 :'(

4

0 回答 0