I'm trying to send an email using form data. I'm adapting the method described at http://www.html-form-guide.com/email-form/php-email-form-attachment.html which uses the PEAR library. I'm testing my site locally via XAMPP.
Here's the code from the top of my page:
<?php
// Pear library includes
include_once('Mail/mail.php');
include_once('Mail/mime.php');
Testing the page produces the following:
Fatal error: Class 'Mail' not found in C:\xampp\php\PEAR\Mail\mail.php on line 51
Here's line 51 from mail.php (I haven't altered the file from the default XAMPP installation):
class Mail_mail extends Mail {
Any help would be much appreciated.
try changing
include_once('Mail/mail.php');
to
include_once('Mail.php');
Related
after trying different ways of using the API from sightengine I can' get it to work, I followed the instructions on their site , installing via composer, but when I try to use it, I get the Class not found error in apache:
PHP Fatal error: Uncaught Error: Class 'Sightengine\\SightengineClient' not found in /var/www/html/photobooth/app.php
PHP file:
<?php
use Sightengine\SightengineClient;
$client = new SightengineClient('xxxxxxx', 'xxxxxxxxx');
Missed to include the file.
When installing using composer, we have to include the file in our code
require_once 'vendor'.DIRECTORY_SEPARATOR.'autoload.php';
This will help you to include the file in code, so you can start using the class/objects
I have aws sdk in current directory. I have included sdk in file like this..
include("Aws/S3/S3Client.php");
use Aws\S3\S3Client;
class myClass{
}
It gives me fatal error like..
Fatal error: Class 'Aws\Common\Client\AbstractClient' not found in /somePath/Aws/S3/S3Client.php on line 117
Please help.
To avoid all these error while sending request or getting response from AWS, set up AWS SDK using http://aws.amazon.com/developers/getting-started/php/, or use
git clone https://github.com/awslabs/aws-php-sample.git
curl -sS https://getcomposer.org/installer | php
php composer.phar install
By installing AWS SDK in this way, you'll get a file at vendor/autoload.php
It'll take care of all the required files into the script.
I had the exact same issue and wasn't able to find an answer anywhere. So, in case anyone has the same problem in the future, for me it was simply a matter of using a version of AWS SDK that was incompatible with my PHP version.
Once I upgraded my server's PHP version it all worked fine.
I am trying to use Swift_Validate::email($email) and I get a php error: PHP Fatal error: Class 'Swift_Validate' not found.
I have the latest version of swiftmailer. Is there some preference settings I need to do?
I have tried including the Validate.php file, but then I get the error: PHP Fatal error: Class 'Swift_DependencyContainer' not found.
I include DependencyContainer.php and I get the error PHP Fatal error: Class 'Swift_DependencyException' not found.
I include DependencyException.php and I get the error: Class 'Swift_SwiftException' not found.
I include SwiftException.php and I still get the same error.
I think I must not have the preferences set up correctly. I am calling:
"require_once($dir.'/swift/swift_required.php');"
The code I am using for the validation is:
if (!Swift_Validate::email($email))
{ $error = true; }
Any help would be greatly appreciated. Using latest Apache and PHP.
Try require_once dirname( __FILE__) . '/lib/swift_required.php'; to use the built-in autoloader, where lib is subfolder of folder where is the current file ( for default directory structure of the library )
I am attempting to use require to load the ExcelPHP API to manipulate CSV spreadsheets. I am using EasyPHP 12.1 with PHP 5.4.6, Apache 2.4.2, MySQL 5.5.27 and Xdebug 2.2.1. I am on Windows 7.
When I attempt to run the following code:
require_once('classes/PHPexcel/Autoloader.php');
$mySheet = new PHPExcel();
I get a fatal error:
Notice: Use of undefined constant PHPEXCEL_ROOT - assumed 'PHPEXCEL_ROOT' in C:\Program Files\EasyPHP-12.0\www\Classes\Classes\PHPExcel\Autoloader.php on line 73
Fatal error: Class 'PHPExcel_Shared_ZipStreamWrapper' not found in C:\Program Files\EasyPHP-12.0\www\Classes\Classes\PHPExcel\Autoloader.php on line 31
I have tried commenting out line 31 in the Autoloader.php file, and that prevents the the fatal error but then the API won't work and PHP doesn't recognize the PHPExcel class.
Can someone please help me figure out how to get my library to work? Thanks in advance!
Load the PHPExcel class in your require once, rather than the Autoloader (as Seth) has said. Case-sensitivity is also a potential problem, because your scripts won't transfer without error unless you get it right:
require_once('classes/PHPexcel/Autoloader.php');
should be
require_once('classes/PHPExcel.php');
and the library is PHPExcel, not ExcelPHP as you call it in your subject line
Instead of your current require statement, you should call
require_once('classes/PHPExcel.php');
That file defines the constant PHPEXCEL_ROOT that you are missing, and then calls require_once() on the autoloader file. It also loads the main class PHPExcel that the whole library uses.
This may have come a bit too late as PHPExcel has pivoted to PHPSpreadsheet but if you're still using PHPExcel and you want to use the autoloader, all you have to do is define the PHPExcel root before requiring autoloader.
define('PHPEXCEL_ROOT', dirname(__FILE__).'/');
i use it composer in my custom mvc framework
require_once ROOT . '/vendor/autoload.php';
PHPExcel_Autoloader::Register();
i used PEAR Pager in my Projects . it's works fine in my local server but when i upload it to hosing server it's gaves me fatal error :
Fatal error: Cannot redeclare class PEAR_Common in /usr/lib/php/PEAR/Common.php on line 1123
i don't know what's the problem , how can i solve that ?!
The error message says it all. It seems like the class PEAR_Common is loaded twice. Check your code for includes/requires of this class.
If you are using other pear packages that might load (include) this class before you include your Pear_Pager class then this might be the problem.
Regards,