Forum Moderators: coopster

Message Too Old, No Replies

Include Errors

         

wfernley

2:51 pm on Jul 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi.

I am getting an error when I try to use includes with variables inside.

For example:

This works:

include 'http://localhost/site/lib/users.php';

This doesn't work:

$CFG->wwwroot = "http://localhost/site";'

include $CFG->wwwroot.'/lib/users.php';

For some reason the example that doesn't work, sees the file, but the code doesn't work inside.

Can someone explain this to me? I hope I gave you enough information, if not I can give you more.

Thanks. :)

Wes

wfernley

4:46 pm on Jul 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I thought I would send some more info on this matter.

I am trying to include a file that has my connection to the db. Considering my site has php files not in the root directory i need to call the db from all the pages even the ones not in the root. my include before was include("lib/db_config.php"); but i need it to be include($libdir/db_config.php). When I do this it finds the file, but the site doesnt connect to the DB anymore.

Does anyone know why? :S

Thanks

Wes

Notawiz

10:21 am on Jul 10, 2004 (gmt 0)

10+ Year Member



I successfully tried to put some "sensitive" information outside of the public domain, such as the variables needed to connect to mysql.
To access these, I use

$path="/home/mydomain/hidden/";
require($path."my_special_file.php");

and it works. Perhaps this can help you?

Notawiz

10:24 am on Jul 10, 2004 (gmt 0)

10+ Year Member



To be sure about the content of $path, try this:
$path = $_SERVER["DOCUMENT_ROOT"];
echo "$path";

ergophobe

2:42 pm on Jul 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




$CFG->wwwroot = "http://localhost/site";'

parse error? There's an extra quote.

What do you mean "sees the file"? How do you know the file is being "seen" if it isn't being included?

What happens if you do this instead

echo $CFG->wwwroot.'/lib/users.php';

Tom