开发者

Getting data from a MySQL database that can be used with include()

I have a field in a MySQL data开发者_开发技巧base that contains a varchar. This varchar is intended to be a string that will be used to refer to a file location. For example, /file.php.

I've managed to grab this varchar and store it in a $locationarray using the code below:

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

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

}

However, when I use $locationarray in conjunction with the include() function, nothing is displayed on screen?

Is there a way to get data from a MySQL database that can be used with include()?


The problem isn't with your include code, I suspect it's with the contents of filelocation.

/file.php is an absolute path, so include will look for file.php in the root of your system.

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.

Source: http://uk3.php.net/manual/en/function.include.php

Check your error log - if the file isn't found, the log will tell you exactly where include is looking.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜