www.webdeveloper.com
Results 1 to 4 of 4

Thread: require_once and require

  1. #1
    Join Date
    Nov 2013
    Posts
    2

    require_once and require

    Hi,

    Am using PHPMail.

    If I use require 'PHPMailer/PHPMailerAutoload.php'; or require('PHPMailer/PHPMailerAutoload.php');
    I get this error msg: fatal error PHPMailer class not found
    But if I use require_once('PHPMailer/class.phpmailer.php');
    it works fine.

    Also the strange thing is require 'PHPMailer/PHPMailerAutoload.php'; or require('PHPMailer/PHPMailerAutoload.php');
    works fine on my testing site.

    Can anyone shed some light here?
    Thanks in advance.

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,175
    Either that file does not exist where you are trying to require it but failing, or you (probably actually the web server user account) don't have read permissions on it, or the directory structure is different so it's not in the same location relative to where it's being called from.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Nov 2013
    Posts
    2
    Thanks for your reply. Agreed if the user account doesn't have read permission then how come require_once works fine?

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,175
    At first read, I thought you were saying that the require[_once]() statements were failing, but upon a closer look it appears some other statement that depends on the PHPMailer class having already been defined is failing. Therefore it would seem that something is different between the two environments and/or code bases, as in the test environment you already had the PHPMailer class definition loaded when it was needed, but not in the other environment. Why that would be is impossible to say without diving into the code, whether or not you have an __autoload() function defined incorrectly, or different include_path settings, etc.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles