Jump to content

[SOLVED] Problems with including a PHP file in a seperate directory


CherryT

Recommended Posts

Ok, so here's the problem:

I use a separate PHP file for mySQL database connection information (username, password, and the like), as well as for connecting to the database by simply including a file.

The directories are set up similar to this:

The directory the script is in:

/contentm/install/thescript.php or possibly /www/contentm/install/thescript.php, but the /www/ does not show up on Filezilla's directory listing for my subdomain

The directory which the included stuff is located in is:

/contentm/SQL/

Now, one would think you would just be able to do:

require '../SQL/scripta.php' or die("Error message 1");

but when I execute the script, I get an error message of:

Warning: main(1): failed to open stream: No such file or directory in /home/www/rhyok.freehostia.com/RCM/installer/installer_setupsql.php on line 6

Warning: main(1): failed to open stream: No such file or directory in /home/www/rhyok.freehostia.com/RCM/installer/installer_setupsql.php on line 6

Warning: main(1): failed to open stream: No such file or directory in /home/www/rhyok.freehostia.com/RCM/installer/installer_setupsql.php on line 6

Fatal error: main(): Failed opening required '1' (include_path='.') in /home/www/rhyok.freehostia.com/RCM/installer/installer_setupsql.php on line 6

where line 6 is the first require function.

Am I doing something wrong here?

 

EDIT:

GAAH! I am such a 'tard. You can't use the "...or die();". I'm guessing it's because it's trying to find the directory I entered INCLUDING the "or die();" line. Problem solved.

You should be able to use ..or die, but you have to bracket your values...

 

require ('../SQL/scripta.php') or die("Error message 1");

 

Though the or die in a require is kind of redundant, considering require shoots a fatal error if it fails ;)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.