Jump to content

[SOLVED] require a file from previous directory


grahamb314

Recommended Posts

Hi all,

 

I have a php pqge which requires a php file to connect to a database:

 

<?php 

//connect to the database
require('mysql_connect.php');
?>

I have moved mysql_connect.php to the previous directory so i need to change what I have for the require.

How do I tell it to require the same file name, but in the previous directory?

Thanks!!

Link to comment
Share on other sites

Thanks that works, so how do I go back 2 directories?

 

Just repeat the ../ for each level you need to go back - same with any file, not just PHP, so it works for images, stylesheets, normal pages, anything really. :)

 

require('../../mysql_connect.php');

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.