php - 从可以与 include() 一起使用的 MySQL 数据库中获取数据

标签 php mysql arrays include

我在 MySQL 数据库中有一个包含 varchar 的字段。此 varchar 旨在成为将用于引用文件位置的字符串。例如,/file.php

我已经设法获取这个 varchar 并使用下面的代码将它存储在 $locationarray 中:

$query4 = mysql_query("select filelocation from users where username='$username' limit 1");

while($rowloc = mysql_fetch_assoc($query4))
{
    $locationarray = $rowloc['filelocation'];   

}

但是,当我将 $locationarrayinclude() 函数结合使用时,屏幕上没有任何显示吗?

有没有办法从 MySQL 数据库中获取数据,可以与 include() 一起使用?

最佳答案

问题不在于您的包含代码,我怀疑它与 filelocation 的内容有关。

/file.php 是绝对路径,因此 include 会在系统根目录中查找 file.php

Files are included based on the file path given or, if none is given, the include_path specified. If the file isn't found in the include_path, include() will finally check in the calling script's own directory and the current working directory before failing. The include() construct will emit a warning if it cannot find a file; this is different behavior from require(), which will emit a fatal error.

来源:http://uk3.php.net/manual/en/function.include.php

检查您的错误日志 - 如果找不到该文件,该日志将准确告诉您 include 正在查找的位置。

关于php - 从可以与 include() 一起使用的 MySQL 数据库中获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5382610/

相关文章:

php - 左连接显示 2 个结果,而本应为 0

php - Laravel 5 `belongsToMany` 与 `wherePivot` Eloquent 查询无法正常工作

mysql - 合并多个表生成 View

php - 如何在选项 html 表单上加载 mysql 数据

php - 在 WordPress 中按开始日期然后按开始时间查询

php - 使用符号链接(symbolic link)在 PHP 代码中使用新文件夹

php - MySQL - 根据一个字段中的搜索出现次数对行进行排序

arrays - 为什么不保留空数组和哈希值?

arrays - Flutter 解析来自本地化 JSON 文件的数组

javascript - 映射数组并返回结果