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!!

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

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.