为什么没有查询工作,sqli?

时间:2018-03-09 04:54:25

标签: php mysqli

我正在运行这样一个简单的sqli连接并选择,但我在运行查询时遇到了非常奇怪的错误。

警告:mysqli_fetch_array()要求参数1为mysqli_result,第23行的C:\ xampp \ htdocs \ Webmaster \ run \ forum_mc.php中给出布尔值

警告:mysqli_query():第24行的C:\ xampp \ htdocs \ Webmaster \ run \ forum_mc.php中的空查询 ()

<?php
    $sqli_host = 'localhost';
    $sqli_dbname = 'forum_handling';
    $sqli_username = 'root';
    $sqli_password = ''; //null as defualt



$fhconnect = mysqli_connect($sqli_host, $sqli_username, $sqli_password, $sqli_dbname);

if (!$fhconnect) {
    echo "Error: Unable to connect to MySQL." . PHP_EOL;
    echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
    echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
    exit;
}


    $query = "SELECT Forum Title FROM forum_categories ORDER";
    $result = mysqli_query($fhconnect, $query);


    $row = mysqli_fetch_array($result, MYSQLI_NUM);
    $data = mysqli_query($fhconnect,$row); 
    printf ("%s (%s)\n", $row[0], $row[1]);

    mysqli_close($fhconnect);

?>

2 个答案:

答案 0 :(得分:0)

检查您的字段名称论坛标题您不能在论坛和标题之间留一个空格,也可以按字段名称编写顺序

答案 1 :(得分:0)

您的查询应如下所示:

 $query = "SELECT Forum,Title FROM forum_categories ORDER BY Title";

根据需要改变顺序。