Php mysqli_查询将不会执行

Php mysqli_查询将不会执行,php,mysql,mysqli,lamp,Php,Mysql,Mysqli,Lamp,我目前正在尝试执行一个mysqli\u查询,但是当我运行它时,我被告知查询失败。我不确定问题出在哪里,因为我的php文件正在连接到数据库服务器。下面是我的代码: <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width,

我目前正在尝试执行一个
mysqli\u查询
,但是当我运行它时,我被告知查询失败。我不确定问题出在哪里,因为我的php文件正在连接到数据库服务器。下面是我的代码:

<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="icon" href="../img/favicon.ico">
<link href="css/custom.css" rel="stylesheet" type="text/css" />

<title>Assignment 8: Building a "LAMP" Website for your MySQL Data</title>
</head>
<body>
<div id="container">
    <header>
        <h1><mark>"LAMP" Website for MYSQL Movie Databse<mark></h1>
    </header>

    <section>
    <p>Please include the following notes on your page along with an introduction to the data for your user: 1. The source for your data. Is this meant to be a user-based system? or will the data come from downloads? Are the current data test data only? 2. Write at least one paragraph to describe your project. 3. Write at least one paragraph to describe your project. You might wish to refer to our class discussion on specifications for ideas.</p>

        <?php
            /* Connecting and selecting database */
            include ('/home/as7695/db_files/db_config.php');

            $db_link = new mysqli($db_server, $db_user, $db_password, $db_name);
            if ($db_link->connect_errno) {
            print( "Failed to connect to MySQL: (" .$db_link->connect_errno . ") ".$db_link->connect_error);
            }
            print("<p>Connection: ".$db_link->host_info . "<br />\n");
            print( nl2br("Connected successfully\n"));

            /* Setting variables */
            $nationality = $_POST['nationality'];
            $genre = $_POST['genre'];
            $limit = $_POST['limit'];
            $sortkey = $_POST ['sortkey'];

            /* Performing SQL query using criteria supplied by the user on the HTML form */
            $query = "SELECT CONCAT (movies.title, ' (', movies.release_year, ')') AS Title, CONCAT (movies.rating) AS Rating, CONCAT (directors.first_name, ' ', directors.last_name) AS Director, GROUP CONCAT (actors.first_name, ' ', actors.last_name separator ', ') AS Actors, CONCAT (movies.description) AS Description
            FROM movies
            INNER JOIN directors ON movies.directorID = directors.directorID
            INNER JOIN movie_actors ON movies.movieID = movie_actors.movieID
            INNER JOIN actors ON movie_actors.actorID = actors.actorID
            INNER JOIN movie_genres ON movies.movieID = movie_genres.movieID
            INNER JOIN genres ON movie_genres.genreID = genres.genreID
            WHERE directors.nationality = '$nationality' AND genres.genre_name = '$genre'
            GROUP BY movies.movieID
            ORDER BY movies.release_year '$sortkey'
            LIMIT '$limit'";

            /* Store result as a variable and see how many records are returned */
            $result = mysqli_query($db_link,$query) or die("Query failed : " . mysqli_error());

            /* Closing connection */
            mysqli_close($db_link);
        ?>
    </section>
</div>
</body>
</html>

作业8:为MySQL数据构建一个“LAMP”网站
MYSQL电影数据库的“LAMP”网站
请在您的页面上包括以下注释,并为您的用户介绍数据:1。数据的源。这是一个基于用户的系统吗?或者数据来自下载?当前数据是否仅为测试数据?2.至少写一段描述你的项目。3.至少写一段描述你的项目。您可能希望参考我们关于想法规范的课堂讨论


请在此处以纯文本形式发布代码、错误或文本输出,而不是以图像形式发布,这些图像可能难以阅读,无法复制粘贴以帮助测试代码或在答案中使用,并且对那些使用屏幕阅读器的人不利。您可以编辑问题以在问题正文中添加代码。使用
{}
按钮格式化任何代码块,或使用四个空格缩进以获得相同效果。好的,谢谢。我已经做了改变!请阅读此问题(及相关答案)以了解如何防止SQL注入:。您共享的代码非常不安全。警告:当使用
mysqli
时,您应该使用并将用户数据添加到查询中。不要使用字符串插值或串联来完成此操作,因为您已经创建了严重的错误。不要把<代码> $POST ,<代码> $yGET或任何用户数据直接输入到查询中,如果有人试图利用你的错误,这将是非常有害的。要考虑的一件事是使用面向对象的调用方法来避免错误,就像你在这里调用的“代码< MySqLyError())< /代码>意外。这应该是
mysqli\u error()
,相差一个字符。在面向对象的风格中,
$db_link->error
,这显然是非常不同的,更难忽视。