Forum Moderators: coopster

Message Too Old, No Replies

how to include library files in php program

         

chandran27

6:07 am on Dec 11, 2006 (gmt 0)

10+ Year Member



hi friends

The line below is in my php program:
include 'opendb.php';

But it gives the following error:

PHP Warning: include(opendb.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in C:/...

No such files are present in the php installation. please tell me if any one has the solution for this.

chandran

omoutop

7:05 am on Dec 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Make sure the path of the included file is correct.
Make sure the file exists.

For more info pleae read here [gr.php.net]

mcibor

10:11 pm on Dec 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The function include, require etc. open files relatively to the file opened by the browser:

let's say you have such a dir/file structure:
include/head.php
include/functions.php
index.php

index.php:

<?php
include 'include/head.php';
?>

head.php:

<?php
//include 'functions.php' //will return error
include 'include/functions.php';
?>

Hope this cleares everything
Michal