/    Sign up×
Community /Pin to ProfileBookmark

require_once and require

Hi,

Am using PHPMail.

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

Also the strange thing is [B]require ‘PHPMailer/PHPMailerAutoload.php’;[/B] or [B]require(‘PHPMailer/PHPMailerAutoload.php’);[/B]
works fine on my testing site.

Can anyone shed some light here?
Thanks in advance.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogNov 13.2013 — 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.
Copy linkTweet thisAlerts:
@marverixauthorNov 14.2013 — Thanks for your reply. Agreed if the user account doesn't have read permission then how come [B]require_once[/B] works fine?
Copy linkTweet thisAlerts:
@NogDogNov 14.2013 — 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 [i]something[/i] 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.
×

Success!

Help @marverix spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...