Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Including a file

Status
Not open for further replies.

estrellas

Programmer
Jul 16, 2004
48
US
Hey guys thanks for all your help so far .. i swear my question are gonna be starting to slow down because i'm understanding more stuff. One thing though -

How do I include a file to be read from another php file ...

like here's the thing.

i want to include

dbconnect.php
Code:
<?php $dbuser = 'coolThing'; $dbpass = 'coolPass'; ?>
into all of my files so whenever i decide to change the username or password, i don't have to change all of my files manually.

i've tried to do the include("FILENAME"); and require_once("FILENAME"); but neither of these seem to work. i've changed teh priviledges of dbconnect.php to 777 to hopefully get rid of any problems there but that didn't fix it.

do you guys have any other ideas on how i could get my file to be opened and read?

thanks and cheers!

-------
 

The only thing I can think of is that the Include Path for PHP is not finding your included file, because I do this all the time.

 
Warning: main (connect.php): failed to open stream: No such file or directory

and

Warning: main(): Failed opening connect.php' for inclusion (include_path='.:')

but the file is definitly there. i looked and everything reads that it is there.

-------
 
Where is the file located in relationship to the calling file?
You have the option
a)to specify an absolute path
b) to put the common files in one folder and add the folder to the include_path variable using ini_set()
If the file is physically there, then you can get to it (given the read privileges are correct).
 
thanks so much DRJ478! i didn't know that you had to set the path absolute. i had it set relative and that doesn't work. the who entire ini_set() is over my head, but it's okay since there's only one file i need to include.

thanks so much guys :) cheers!

-------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top