SitePoint Sponsor

User Tag List

Results 1 to 20 of 20
  1. #1
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I am getting a require_once error

    I am getting the fallowing two error please somebody help.

    Code:
    Warning: require_once(error.class.php) [function.require-once]: failed to open stream: No such file or directory in C:\wamp\www\include.all.php on line 2
    
    Fatal error: require_once() [function.require]: Failed opening required 'error.class.php' (include_path='.;C:\php5\pear') in C:\wamp\www\include.all.php on line 2
    Thank you

  2. #2
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    '.;C:\php5\pear'

    ^ is that directory path correct? In particular the bolded characters?

  3. #3
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,509
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    It looks like error.class.php isn't present in C:\wamp\www\

  4. #4
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    @Evoken: I don't really think that path is really important.

    Does c:\wamp\www\error.class.php exist? Sure it's not in a folder?
    Last edited by Jake Arkinstall; Apr 21, 2009 at 10:03.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  5. #5
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have made a site definition in dreamweaver named ratingsystem in the remote folder C:\wamp\www\ and yes both files are included in te remote folder but still the error keep coming up.

    Code:
    <?php
      require_once("error.class.php");
      require_once("database.class.php");
      require_once("rating.class.php");
      
    ?>
    That's the way I am pathing it maybe that's the problem

    For further refernces I will include the site definition for rating System which i have set up in as fallows in Dreamweaver.

    For local info
    Site name: rating System
    Local root folder: C:\RatingSystem\HTTP
    address: http://localhost/

    For Remote Info
    Access: Local/Network
    Remote folder: C:\wamp\www\For Testing Server
    Server model: PHP MysqlAccess: Local/Network

    Testing server
    folder: C:\wamp\www\
    URL prefix: http://localhost/
    Last edited by co.ador; Apr 22, 2009 at 12:35.

  6. #6
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Before the require_once, put the following code:
    PHP Code:
    echo dirname(__FILENAME__) . '<hr /><pre>';
    var_dump(file_exists('error.class.php'));
    echo 
    '</pre>'
    What is output when you try to run the file?
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  7. #7
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you will excuse me but where do I find the output, to show you

    With your new suggestion the whole coding would look like this

    Code:
    <?php
      echo dirname(__FILENAME__) . '<hr /><pre>';var_dump(file_exists('error.class.php'));echo '</pre>';     
      require_once("error.class.php");
      require_once("database.class.php");
      require_once("rating.class.php");
    
    ?>
    Just want to make sure.
    Last edited by co.ador; Apr 22, 2009 at 12:35.

  8. #8
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know if you meant output after puting the code you gave but this is what happens after I put the code you gave me


    Code:
    Notice: Use of undefined constant __FILENAME__ - assumed '__FILENAME__' in C:\wamp\www\classes\include.all.php on line 2
    .
    --------------------------------------------------------------------------------
    
    bool(true)
    
    
    Warning: require_once(c:\wamp\www\database.class.php) [function.require-once]: failed to open stream: No such file or directory in C:\wamp\www\classes\include.all.php on line 3
    
    Fatal error: require_once() [function.require]: Failed opening required 'c:\wamp\www\database.class.php' (include_path='.;C:\php5\pear') in C:\wamp\www\classes\include.all.php on line 3

  9. #9
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Ahh, that should have been __FILE__.

    Anyway, the var_dump proves that the file error.inc.php exists.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  10. #10
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    with __FILE__ instead it shows



    Code:
    C:\wamp\www\classes
    --------------------------------------------------------------------------------
    
    bool(true)


    Any suggestion on what might be causing the problem?

  11. #11
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    hmmm....

    Just a wild stab in the dark:
    PHP Code:
    <?php
    require_once('classes/error.class.php');
    require_once(
    'classes/database.class.php');
    require_once(
    'classes/rating.class.php');
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  12. #12
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i tried
    PHP Code:
    <?php
    require_once('classes/error.class.php');
    require_once(
    'classes/database.class.php');
    require_once(
    'classes/rating.class.php'); ?>
    but still it keeps bringing the same error.


    Code:
    Warning: require_once(error.class.php) [function.require-once]: failed to open stream: No such file or directory in C:\wamp\www\include.all.php on line 2
    
    Fatal error: require_once() [function.require]: Failed opening required 'error.class.php' (include_path='.;C:\php5\pear') in C:\wamp\www\include.all.php on line 2
    I am thinking that it might be the site definition that is not well set up.

    I don't know still doesn't go beyon that point.

  13. #13
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    co.ador, I think you're making some changes here without sharing them with us. It makes it more difficult for people to help you when you do that.

    In your first post, php couldn't find error.class.php but in post #7 and 8, it did find it. Yet according to the code posted, you've changed nothing which would affect this.

    Anyway, a good way to see how php tries to resolve a relative filepath is by discovering what php's current working directory is at that specific point in the code. Relative filepaths are resolved against this current working directory*.

    PHP Code:
    echo getcwd() . DIRECTORY_SEPARATOR 'error.class.php';
    require 
    'error.class.php';
    echo 
    getcwd() . DIRECTORY_SEPARATOR 'database.class.php';
    require 
    'database.class.php'
    That will show you where php is looking for those two files.


    *the value include_path can alter and complicate the behavior a bit, but doesn't appear to be the case for you.

  14. #14
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you Crmalibu

    what I did before was use what arkinstall suggested me to try the code below to see if the file error.class.php existed. it did existed

    PHP Code:
    <?php
      
    echo dirname(__FILE__) . '<hr /><pre>';var_dump(file_exists('error.class.php'));echo '</pre>';     
      require_once(
    "error.class.php");
      require_once(
    "database.class.php");
      require_once(
    "rating.class.php");
    ?>
    Now the code you are suggesting me to put would look like the one below?

    [PHP] <?php echo getcwd() . DIRECTORY_SEPARATOR . 'error.class.php';
    require 'error.class.php'; echo getcwd() .
    DIRECTORY_SEPARATOR . 'database.class.php';
    require 'database.class.php';
    require_once("error.class.php");
    require_once("database.class.php");
    require_once("rating.class.php");
    PHP]

    Because i tried the one above and the results or output in the Internetexplorer were as fallows:

    C:\wamp\www\classes\error.class.phpC:\wamp\www\classes\database.class.php
    Warning: require_once(classes/error.class.php) [function.require-once]: failed to open stream: No such file or directory in C:\wamp\www\classes\include.all.php on line 3

    Fatal error: require_once() [function.require]: Failed opening required 'classes/error.class.php' (include_path='.;C:\php5\pear') in C:\wamp\www\classes\include.all.php on line 3
    Last edited by co.ador; Apr 22, 2009 at 12:36.

  15. #15
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One thing I need to say guys i am pressing F12 from the rating-example.php file that has the fallowing code

    PHP Code:
    <?php
      
    require_once("include.all.php");
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>CSS Star Rating System fully functional using AJAX</title>
        <link type="text/css" href="styles/rating.css" rel="stylesheet" media="all" />
        <script type="text/javascript" src="scripts/prototype.js"></script>
        <script type="text/javascript" src="scripts/rating.js"></script>
      </head>
      <body>
        <h4>Demo Rating System:</h4>
        <?php
          $ratingData 
    Rating::OutputRating('demo');
          
          if (
    Error::HasErrors())
          {
            echo 
    Error::ShowErrorMessages();
            
    Error::ClearErrors();
          }
          else
          {
            echo 
    $ratingData;
          }
        
    ?>
        <?php
          $ratingData 
    Rating::OutputRating('paul');
          
          if (
    Error::HasErrors())
          {
            echo 
    Error::ShowErrorMessages();
            
    Error::ClearErrors();
          }
          else
          {
            echo 
    $ratingData;
          }
        
    ?>
        <?php
          $ratingData 
    Rating::OutputRating('matt');
          
          if (
    Error::HasErrors())
          {
            echo 
    Error::ShowErrorMessages();
            
    Error::ClearErrors();
          }
          else
          {
            echo 
    $ratingData;
          }
        
    ?>
      </body>
    </html>
    <?php
      Database
    ::DeInitialize();
    ?>
    Then from there it requires the include.all.php file which has the fallowing code.

    [PHP]<?php
    require_once("error.class.php");
    require_once("database.class.php");
    require_once("rating.class.php");
    [PHP]

    And that when the error occurs if I am not wrong executing the second line
    PHP Code:
    require_once("error.class.php"); 
    a couple of observations I have done is that i am using dreamweaver CS3 from Torrentscan.com as a php editor or developer, Wampserver which includes Mysql, Apache and PHP. I have observed that instead of the blue php tags as shown here,
    PHP Code:
    <?php ?>
    In dreamweaver are shown in Red like this
    Code:
    <?php ?> 
    I know this observations might not be relevant to the faced matter but just in case you guys know.
    Last edited by co.ador; Apr 22, 2009 at 12:36.

  16. #16
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    post the output of this
    PHP Code:
    print_r(scandir('C:\wamp\www\classes')); 

  17. #17
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Excuse me I am new to php how can I post it?

    just have to write it down in dreamweaver?

  18. #18
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    copy the output to this forum so we can all read it.

  19. #19
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I appologize about that

    Thank you!

    What I did was

    [PHP]<?php
    print_r(scandir('C:\wamp\www\classes'));
    require_once("error.class.php");
    require_once("database.class.php");
    require_once("rating.class.php");
    PHP]

    This is the output

    Array ( [0] => . [1] => .. [2] => database.class.php [3] => error.class.php [4] => include.all.php [5] => rating.class.php )
    Last edited by co.ador; Apr 22, 2009 at 12:37.

  20. #20
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the output from the rating_example.php file explained in post #15

    Array ( [0] => . [1] => .. [2] => database.class.php [3] => error.class.php [4] => include.all.php [5] => rating.class.php )
    Warning: require_once(error.class.php) [function.require-once]: failed to open stream: No such file or directory in C:\wamp\www\include.all.php on line 2

    Fatal error: require_once() [function.require]: Failed opening required 'error.class.php' (include_path='.;C:\php5\pear') in C:\wamp\www\include.all.php on line 2

    What I did was:

    PHP Code:
    <?php 
      print_r
    (scandir('C:\wamp\www\classes')); 
      require_once(
    "include.all.php");
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>CSS Star Rating System fully functional using AJAX</title>
        <link type="text/css" href="styles/rating.css" rel="stylesheet" media="all" />
        <script type="text/javascript" src="scripts/prototype.js"></script>
        <script type="text/javascript" src="scripts/rating.js"></script>
      </head>
      <body>
        <h4>Demo Rating System:</h4>
        <?php
          $ratingData 
    Rating::OutputRating('demo');
          
          if (
    Error::HasErrors())
          {
            echo 
    Error::ShowErrorMessages();
            
    Error::ClearErrors();
          }
          else
          {
            echo 
    $ratingData;
          }
        
    ?>
        <?php
          $ratingData 
    Rating::OutputRating('paul');
          
          if (
    Error::HasErrors())
          {
            echo 
    Error::ShowErrorMessages();
            
    Error::ClearErrors();
          }
          else
          {
            echo 
    $ratingData;
          }
        
    ?>
        <?php
          $ratingData 
    Rating::OutputRating('matt');
          
          if (
    Error::HasErrors())
          {
            echo 
    Error::ShowErrorMessages();
            
    Error::ClearErrors();
          }
          else
          {
            echo 
    $ratingData;
          }
        
    ?>
      </body>
    </html>
    <?php
      Database
    ::DeInitialize();
    ?>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •