PHP包含while mysql查询


PHP include while mysql query

代码

$groups = mysqli_query($con, "SELECT * FROM Exten WHERE username='" . $user . "'") or die(mysqli_error($con));
while ($rows = mysqli_fetch_array($groups)) {
    $userindex = mysqli_query($con, "SELECT * FROM Exten WHERE Group1='" . $rows['Group1'] . "''" . include "var/www/html/groups.php" . "'") or die(mysqli_error($con));
    while ($row = mysqli_fetch_array($userindex)) {
    echo "<br>";
    echo $row['Index'];
    }
}

输出消息为

警告:include(var/www/html/groups.php'): failed to open stream: No

第38行/var/www/html/login.php中的文件或目录

警告:include(): Failed open 'var/www/html/groups.php " for包含(include_path='.:/usr/share/php')到/var/www/html/login.php在第38行你有一个错误在你的SQL语法;查看手册对应于MySQL服务器版本,以便使用正确的语法在第1行" 01 " '附近

我需要包含我的php文件到我的mysql查询。

PHP文件包含

OR Group2='" . $rows['Group2'] . "'
OR Group3='" . $rows['Group3'] . "'
OR Group4='" . $rows['Group4'] . "'
OR Group5='" . $rows['Group5'] . "'
OR Group6='" . $rows['Group6'] . "'
OR Group7='" . $rows['Group7'] . "'
OR Group8='" . $rows['Group8'] . "'
OR Group9='" . $rows['Group9'] . "'
OR Group10='" . $rows['Group10'] . "'

文件路径不正确,需要以正斜杠/开头来读:
/var/www/html/groups.php

还有,为什么在MySQL查询中使用include语句?

文件路径似乎在末尾有一个额外的单引号:

Warning: include(var/www/html/groups.php')

如果你使用:

include ("var/www/html/groups.php")

include ("/var/www/html/groups.php")

加括号而不是引号?此外,请检查您的引号,否则您的查询可能会中断。

如果var在根目录,则写成include "./var/www/html/groups.php"

$userindex = mysqli_query($con, "SELECT * FROM Exten WHERE Group1='" . $rows['Group1'] . "''" . include "./var/www/html/groups.php" . "'") or die(mysqli_error($con));