failed to open stream. helpp meeee:-<
Posted by: niranjnn01 (202.83.34.---)
Date: April 09, 2007 09:00AM

hello..
i am a beginer in php..bought my text 2-3 days back actually..
i got this error when i tried executing a code from text...
it should create a database and define two tables user anad access_log!


Warning: include(./common_db.inc) [function.include]: failed to open stream: No such file or directory in C:\wamp\www\dbsample.php on line 2

Warning: include() [function.include]: Failed opening './common_db.inc' for inclusion (include_path='.;C:\php5\pear') in C:\wamp\www\dbsample.php on line 2

Fatal error: Call to undefined function db_connect() in C:\wamp\www\dbsample.php on line 23

please help em out!! i dunno what to do!! :-(
________________________________________
thsi is the code!

<?php
include "./common_db.inc";

$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"winking smiley) die(sql_error());

echo "succesfully created the $dbname database.<br>";

if(!mysql_select_db($dbname)) die(sql_error());

if(!mysql_select_db("CREATE TABLE $user_tablename ($user_table_def)"winking smiley) die(sql_error());

if(!mysql_query("CREATE TABLE$access_log_tablename ($access_log_table_def)"winking smiley)

die(sql_error());

echo "successfully created the $user_tablename and$access_log_tablename tables.";

?>

Options: ReplyQuote
Re: failed to open stream. helpp meeee:-
Posted by: CyberSpatium (71.237.217.---)
Date: April 09, 2007 10:37AM

if common_db.inc is located in the same directory as the php script you are using then use:
include "common_db.inc";

if the common_db.inc file is one directory below where your php script is then use:
include "../common_db.inc";

if common_db is in a directory above where your php script is use:
include "somedirectory/common_db.inc";



CyberSpatium
----------------------
WAMP English Forum Admin

Need help? Check out my WAMP User Manual/Guide here!


Please visit my latest website Clarify Loans:
clarifyloans.com

Options: ReplyQuote
Re: failed to open stream. helpp meeee:-
Posted by: niranjnn01 (202.83.32.---)
Date: April 10, 2007 03:16AM

i tried to find common_db.inc ...but its no where to b found!.....
i am excuting the program from the root directory which is www.

shouldnt it b finding it automatically?

i searched for common_db.in but dint find it!

Options: ReplyQuote
Re: failed to open stream. helpp meeee:-
Posted by: niranjnn01 (202.83.35.---)
Date: April 10, 2007 03:38PM

guys..ne one got d content of d file common_db.inc?
cuz i learned dat i wont b able to run d code using wamp!!
n dat i hafto write d content of that file in d place of include!!

please correct me if i am wrong, n do suggest what i can do.

n do post if neone has got contents of d file common_db.inc

thanks

Options: ReplyQuote
Re: failed to open stream. helpp meeee:-
Posted by: yfastud (72.236.169.---)
Date: April 10, 2007 04:22PM

I'm afraid that file include w/ your script, so you should follow cyber's suggestion or if using it for long term, insert it in php.ini

Have fun,

[www.jlbn.com] (testing WAMPS on Vista)
[test.jlbn.com] (testing codes on Vista)

Win Vista Business
Apache 2.2.4
MySQL 5.2.3 F-A
PHP 5.2.1
SSL 0.9.8D

phpMyAdmin 2.10.0.2

Options: ReplyQuote
Re: failed to open stream. helpp meeee:-
Posted by: CyberSpatium (71.237.217.---)
Date: April 10, 2007 05:49PM

you can not include any file using include() and expect php to find it. you need to point have the correct path to that file.


CyberSpatium
----------------------
WAMP English Forum Admin

Need help? Check out my WAMP User Manual/Guide here!


Please visit my latest website Clarify Loans:
clarifyloans.com

Options: ReplyQuote
Re: failed to open stream. helpp meeee:-
Posted by: niranjnn01 (202.83.34.---)
Date: April 11, 2007 02:55AM

but i cant find the file common_db.inc in my computer...

if neone of u guys have d file, do post it here..
thanks.

ps: but shouldnt these files come with wamp??

Options: ReplyQuote
Re: failed to open stream. helpp meeee:-
Posted by: CyberSpatium (71.237.217.---)
Date: April 11, 2007 06:54AM

post this question in the support forum for whavever script you are trying to install.


CyberSpatium
----------------------
WAMP English Forum Admin

Need help? Check out my WAMP User Manual/Guide here!

Please visit my latest website Clarify Loans:
clarifyloans.com


Like my free support? Help support me by making a donation today!

Options: ReplyQuote


Sorry, only registered users may post in this forum.