Hi Kishore,

Just a couple of ideas:

1) Avoid using the HTTP protocol for your includes (slower, more overhead). Use
the server machine's native file system. The actual path to the file will vary
based on the OS (Linux vs Windows) and how the user areas have been configured,
but would typically be something like this...

/home/your_account_name/public_html/connect.php

NOTE: One potential security issue with the above--if at all possible, keep the
connection data OUTSIDE the document root of the web server. In this example,
if something were to go wrong with the server and it decided not to process the
PHP file but rather serve it (as an unrecognized type), then a web visitor
could potentially see the source code containing your password info. 

Alternately, put all included files in their own folder, and use an .htaccess
directive to deny permissions to the specific folder where the protected files
reside (though this is not 100% secure if for some reason the server decides
not to read the .htaccess file).

For any included files that reside under the document root, I use the following
to specify the path to the files:

  include($_SERVER['DOCUMENT_ROOT'] . '/includes/db_connect.php');

The advantage to this--moving to a different server becomes much less of a
headache. Or even better:

  define('INCLUDES',$_SERVER['DOCUMENT_ROOT'] . '/includes');
  include(INCLUDES . '/db_connect.php');

Now if you've got includes in mutlple places and you want to change where they
reside, you can do so from one place.

And of course, it always helps to make sure you have read permissions for the
file set correctly. 

Hope this helps,
Gunther
http://www.gunthersoft.com


--- Kishore Balla <[EMAIL PROTECTED]> wrote:

> Hi all,
> 
> I'm facing a problem with including the database config file..
> 
> I kept database variables in a config file like this..
> 
> connect.php
> 
> <?php
> 
> $dbhost='something';
> $dbuser='something';
> $dbpass='something';
> $dbname='something';
> ?>
> 
> then in my home.php file I've included that file ( both connect.php and
> home.php are in same folder );
> 
> <?php
> 
> include 'connect.php';
> 
> $db=mysql_connect($dbhost,$dbuser,$dbpass);
> mysql_select_db($dbname,$db);
> 
> //some actions
> 
> ?>
> 
> The above thing worked fine until I moved the config file to root
> directoryso that It will be available to all scripts..
> 
> the changes I've made to the script.. home.php
> 
> <?php
> 
> include 'http://domain.com/connect.php';
> 
> $db=mysql_connect($dbhost,$dbuser,$dbpass);
> mysql_select_db($dbname,$db);
> 
> //some actions
> 
> ?>
> 
> the above code this throwing errors.. what could the problem...
> 
> thanx in advance...
> 
> --
> KISHORE
> 
> 
> [Non-text portions of this message have been removed]
> 
> 
> 
> 
> Community email addresses:
>   Post message: [email protected]
>   Subscribe:    [EMAIL PROTECTED]
>   Unsubscribe:  [EMAIL PROTECTED]
>   List owner:   [EMAIL PROTECTED]
> 
> Shortcut URL to this page:
>   http://groups.yahoo.com/group/php-list 
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 
> 
> 



                
__________________________________ 
Yahoo! Music Unlimited 
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/HKFolB/TM
--------------------------------------------------------------------~-> 

Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 




Reply via email to