error while including


i am a beginner in php
i got the following error when i tried to execute a code frm text

Warning: include( [function.include]: failed to open stream: No such file or directory in C:wampwwwdbsample.php on line 3

Warning: include() [function.include]: Failed opening ‘’ for inclusion (include_path=’.;C:php5pear’) in C:wampwwwdbsample.php on line 3

Fatal error: Call to undefined function db_connect() in C:wampwwwdbsample.php on line 23

i am using wamp5 (a pakage of php, mysql and apache server) for developing a php report generator.

i just tried out this sample program n i dunno how to resolve this problem!
please help!



please submit your full coding…thank you


this is the full code

<?php //include "./"; include ""; $dbname = "sample_db"; $user_tablename = 'user'; $user_table_def = "usernumber MEDIUMINT(10) DEFAULT '0' NOT NULL AUTO_INCREMENT, "; $user_table_def .= "userid VARCHAR(8) BINARY NOT NULL,"; $user_table_def .= "userpassword VARCHAR(20) BINARYNOT NULL,"; $user_table_def .= "username VARCHAR(30) NOT NULL,"; $user_table_def .= "userposition VARCHAR(50) NOT NULL,"; $user_table_def .= "useremail VARCHAR(50) NOT NULL,"; $user_table_def .= "userprofile TEXT NOT NULL,"; $user_table_def .= "UNIQUE usernumber (usernumber)"; $access_log_tablename = "access_log"; $access_log_table_def = "page VARCHAR(250) NOT NULL,"; $access_log_table_def .= "userid VARCHAR(8) BINARY NOT NULL,"; $access_log_table_def .= "visitcount MEDIUMINT(5) DEFAULT '0' NOT NULL,"; $access_log_table_def .= "accessdate TIMESTAMP(14) ,KEY page (page),"; $access_log_table_def .= "PRIMARY KEY (userid,page)"; $link_id = db_connect(); if(!$link_db) die(sql_error()); if(!mysql_query("CREATE DATABASE $dbname")) die(sql_error()); echo "succesfully created the $dbname database.
"; if(!mysql_select_db($dbname)) die(sql_error()); if(!mysql_select_db("CREATE TABLE $user_tablename ($user_table_def)")) die(sql_error()); if(!mysql_query("CREATE TABLE$access_log_tablename ($access_log_table_def)")) die(sql_error()); echo "successfully created the $user_tablename and$access_log_tablename tables."; ?>


That bold part is all you need to know :wink:


yea…the file “” is not included, and the compiler cant find it…cuz it failed to open stream

its dis the error all about?

but how do i include the file

i think the syntax is

include “./”;
(i have it disabled in the full code i gave… but its not working when i enable it either!

is the syntax correct or should i do smthing with the settings of wamp5?
please help me! :cry:


First of all: PHP doesn’t get compiled. It gets interpreted (by the PHP engine that Apache calls, to be exact). Secondly: incorrect syntax generates a syntax error, not an include error :wink: Third: failed to open stream is a direct cause of the part that I made bold: NO SUCH FILE OR DIRECTORY. So the problem is not in your PHP script, but in your filesystem.


thank u zyp for the information…
so…my file system is creating all d trouble isnt it?

so…emmm…how do i resolve it? :o


Uuhm, by putting a file named dbsample.php in the folder C:wampwww on your system?


nono… www is the root directory and when i save and run simple php programs(with no inclusion n all) from there, it works fine

please see this.
Failed opening ‘’ for inclusion (include_path=’.;C:php5pear’) in C:wampwwwdbsample.php on line 3


Ohw crap, you’re right :confused:
It’s not dbsample.php that it’s looking for, it’s that it can’t find (so it’s probably (searching) in the wrong directory). That’s the file you want the PHP script to find.