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.

Link to comment
Share on other sites

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 ;)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.