Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
failed to open stream
Old 03-26-2010, 07:51 AM failed to open stream
Novice Talker

Posts: 5
Name: Ting
Trades: 0
I meet with a fatal error when I am developing my website:

failed to open stream: No such file or directory


Details (code):
PHP Code:
<?php  /// Moodle Configuration File

unset($CFG);

$CFG->dbtype    'mysql';
$CFG->dbhost    'localhost';
$CFG->dbname    'moodle';
$CFG->dbuser    =&#8217;     ’;
$CFG->dbpass    =&#8217;    ’;
$CFG->dbpersist =  xxxx;
$CFG->prefix    = &#8216;   ';

$CFG->wwwroot   'http://localhost/moodle';
$CFG->dirroot   'D:\xampp\htdocs\moodle';
$CFG->dataroot  'D:\xampp/moodledata';
$CFG->admin     'admin';

$CFG->directorypermissions xxxx;  // try xxxx  on a server in Safe Mode

$CFG->passwordsaltmain '&;l(~,Anx6fRxn;

require_once("$CFG->dirroot/lib/setup.php");
// MAKE SURE WHEN YOU EDIT THIS FILE THAT THERE ARE NO SPACES, BLANK LINES,
// RETURNS, OR ANYTHING ELSE AFTER THE TWO CHARACTERS ON THE NEXT LINE.
?>


Please help me to solve it, thank you!

Last edited by chrishirst; 03-26-2010 at 08:01 AM..
kcting is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-26-2010, 07:55 AM Re: failed to open stream
Novice Talker

Posts: 5
Name: Ting
Trades: 0
Warning: main(D:\xampp\htdocs\moodle/lib/setup.php): failed to open stream: No such file or directory in /Users/student/ting/Sites/htdocs/moodle/config.php on line 22

Fatal error: main(): Failed opening required 'D:\xampp\htdocs\moodle/lib/setup.php' (include_path='.:/Applications/xampp/xamppfiles/lib/php') in /Users/student/ting/Sites/htdocs/moodle/config.php on line 22
kcting is offline
Reply With Quote
View Public Profile
 
Old 03-26-2010, 08:03 AM Re: failed to open stream
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Make sure the files and the path exists.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-26-2010, 08:45 AM Re: failed to open stream
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
This is a windows path
Quote:
D:\xampp\htdocs\moodle/lib/setup.php
This is a unix path:
Quote:
/Users/student/ting/Sites/htdocs/moodle/config.php
They are not compatible as it.
It means that you have developed something on a windows machine and uploaded it on an unix server, and not checked the path(s) in your code.

You must either include a different file if you are on dev or prod, or use a relative path based on the
PHP Code:
$_SERVER['DOCUMENT_ROOT'
variable.

http://www.webmaster-talk.com/php-fo...g-include.html
http://www.webmaster-talk.com/php-fo...e-problem.html
http://www.webmaster-talk.com/php-fo...locations.html
__________________
Only a biker knows why a dog sticks his head out the window.

Last edited by tripy; 03-26-2010 at 08:49 AM..
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 03-26-2010, 11:21 PM Re: failed to open stream
Novice Talker

Posts: 5
Name: Ting
Trades: 0
Hi, thank you all for your reply.

Hi Tripy, I don't know where to put this code.

PHP Code:
$_SERVER['DOCUMENT_ROOT']

I got no idea of editing code because I am just a newbie. Could you please explain to me? I am grateful for your help.
kcting is offline
Reply With Quote
View Public Profile
 
Old 03-27-2010, 12:37 PM Re: failed to open stream
Novice Talker

Posts: 9
Trades: 0
With this code:

$CFG->dirroot = 'D:\xampp\htdocs\moodle';
$CFG->dataroot = 'D:\xampp/moodledata';

You are indicating that the files are located in a the 'xampp' folder on your 'D' drive (on a Windows system). However, when you run the script certain files that need to be included are searched for in this folder, and not found. Consequently, there is an error indicating that required files could not be found. So you need to change these directory references to the correct ones. From the error it appears that your script is located at:

/Users/student/ting/Sites/htdocs/

(a UNIX path, not Windows).

So try changing the aforementioned variables to:

$CFG->dirroot = '/Users/student/ting/Sites/htdocs/moodle';
$CFG->dataroot = '/Users/student/ting/Sites/htdocs/moodledata';

That might work...
paul.h is offline
Reply With Quote
View Public Profile
 
Old 03-29-2010, 11:05 AM Re: failed to open stream
Novice Talker

Posts: 5
Name: Ting
Trades: 0
<?php /// Moodle Configuration File

unset($CFG);

$CFG->dbtype = 'mysql';
$CFG->dbhost = 'localhost';
$CFG->dbname = 'moodle';
$CFG->dbuser = 'xxx';
$CFG->dbpass = 't';
$CFG->dbpersist = false;
$CFG->prefix = 'mdl_';

$CFG->wwwroot = 'http://localhost/moodle';
$CFG->dirroot = 'D:\xampp\htdocs\moodle';
$CFG->dataroot = 'D:\xampp\moodledata';
$CFG->admin = 'admin';

$CFG->directorypermissions = ; // try on a server in Safe Mode

$CFG->passwordsaltmain = '&;Zl(~,An#[w[=%';

require_once("$CFG->dirroot/lib/setup.php");
// MAKE SURE WHEN YOU EDIT THIS FILE THAT THERE ARE NO SPACES, BLANK LINES,
// RETURNS, OR ANYTHING ELSE AFTER THE TWO CHARACTERS ON THE NEXT LINE.




Warning: main(D:\xampp\htdocs\moodle/lib/setup.php): failed to open stream: No such file or directory in /Users/student/ting/Sites/xampp/moodle/config.php on line 22

Fatal error: main(): Failed opening required 'D:\xampp\htdocs\moodle/lib/setup.php' (include_path='.:/Applications/xampp/xamppfiles/lib/php') in /Users/student/ting/Sites/xampp/moodle/config.php on line 22
?>

Last edited by kcting; 03-29-2010 at 11:08 AM..
kcting is offline
Reply With Quote
View Public Profile
 
Old 03-29-2010, 02:44 PM Re: failed to open stream
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
No, as paul.h told you, you need to modify your config file to match your server.
The offending lines are
PHP Code:
$CFG->wwwroot   'http://localhost/moodle';
$CFG->dirroot   'D:\xampp\htdocs\moodle';
$CFG->dataroot  'D:\xampp\moodledata'
who are fine for your development environment, but not for the productive one.

There is no D: drive on the server!
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to failed to open stream
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.59370 seconds with 12 queries