Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    please: need help with "excelwriter.class.php"

    Please:

    (1) I'm trying to use some PHP code that I've copied from the internet that is a "black box" to me.

    (2) The code gets good reviews from people who have used it successfully. But I don't understand PHP well enough to know why it won't work for me.

    (3) Could anyone help, please?

    (4) I'm trying to use it in an HTML page to write MYSQL table data to an Excel file using PHP.

    (5) The part that is apparently failing for me is this:

    include_once("excelwriter.class.php");

    (6) I get this kind of error:

    Warning: include_once(excelwriter.class.php) [function.include-once]: failed to open stream: No such file or directory in D:\xxxxx on line 148

    (7) Could someone step me through what's necessary to resolve this?

    (8) Apparently I need to create a class of some kind in some directory on my webserver -- and I have no clue how to do that.

    (9) I'm entirely unfamiliar with "classes" and so need real "php for dummies" kind of help to do this --step by step . . .

    Thanks, Malcolm.

  • #2
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    include_once() (or any other include/require function) will look for the specified file in it's parameter. So, include_once("excelwriter.class.php") will look for the file excelwriter.class.php in the same directory as the script running the include. You can specify either a relative or explicit path to direct the include to your file.

    Your error message, specifically, means it can't find that file.
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

  • #3
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by BluePanther View Post
    include_once() (or any other include/require function) will look for the specified file in it's parameter. So, include_once("excelwriter.class.php") will look for the file excelwriter.class.php in the same directory as the script running the include. You can specify either a relative or explicit path to direct the include to your file.

    Your error message, specifically, means it can't find that file.
    (1) I apreciate your help.

    (2) I added a blank "excelwriter.class.php" file to the directory -- as you recommended.

    (3) Looking more closely at the code . . . I'm actually trying to execute a "require" rather than an "include" of that file (sorry):

    ====> require_once("excelwriter.class.php");

    (4) I'm now getting this error:

    ====> Fatal error: Class 'ExcelWriter' not found in D:\Hosting\xxx.php on line 15

    (5) And this is what I am fundamentally confused about.

    (6) Do I only need a file in the directory . . . or does the file TYPE also need to be defined in some way somewhere?

    (7) The place where I copied this code from had the following comment about it:

    "Include phpexcel class file along with your config file and make its object with excel file name passed parameter in constructor"

    (8) But I couldn't figure out what that means . . .

    Thanks again, Malcolm.

  • #4
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    Quote Originally Posted by MalcolmW View Post
    (1) I apreciate your help.

    (2) I added a blank "excelwriter.class.php" file to the directory -- as you recommended.

    (3) Looking more closely at the code . . . I'm actually trying to execute a "require" rather than an "include" of that file (sorry):

    ====> require_once("excelwriter.class.php");

    (4) I'm now getting this error:

    ====> Fatal error: Class 'ExcelWriter' not found in D:\Hosting\xxx.php on line 15

    (5) And this is what I am fundamentally confused about.

    (6) Do I only need a file in the directory . . . or does the file TYPE also need to be defined in some way somewhere?

    (7) The place where I copied this code from had the following comment about it:

    "Include phpexcel class file along with your config file and make its object with excel file name passed parameter in constructor"

    (8) But I couldn't figure out what that means . . .

    Thanks again, Malcolm.
    I didn't recommend that at all. I said you need to direct your include (or require) to the valid file. The error you're getting means that the definition for ExcelWriter couldn't be found - I'm guessing it's in the REAL excelwriter.class.php. PHP, like any other language, isn't psychic - everything needs to be defined.
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.


  •  

    Posting Permissions

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