0

I am having a folder called "db". where it contains 3 files which calls from the mail file "connect.php".

I created a new file in root directory and wrote a function

include "db/connect.php");
echo $connstring;

Here I am not getting any output, the $connstring is defined in another file in "db" folder named as "config.php" which is included in beginning of the "connect.php"

3
  • nothing is showing or you're getting an error. Which is it? What is the error? Commented Apr 22, 2011 at 7:23
  • a bracket is missing at the include statement Commented Apr 22, 2011 at 7:25
  • 2
    @dany in fact you don't need brackets at all with include/require so you could say there's a bracket that shouldn't be there too ;-) Commented Apr 22, 2011 at 7:31

2 Answers 2

4

You have written wrong code for include function.

You should try this,

include ("db/connect.php");
echo $connstring;
Sign up to request clarification or add additional context in comments.

1 Comment

Or this: include 'db/connect.php'; The PHP documentation doesn't explicitly tell it but you don't need brackets with include/require
0

I exactly was looking hot to include the files from different directories correctly.

This is how I got the code to achieve this from one of the project on Zend.

set_include_path( dirname(dirname(dirname(dirname(FILE)))) . DIRECTORY_SEPARATOR . 'library' );

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.