Issues with using PHP Swift Mailer - php

What I have done:
) Downloaded Swift-4.1.5.tar
) Extracted it
) Uploaded to my host in /public_html/domain/lib using FileZilla
) Made a new script using the code below.
) Opened it in the Browser and I got the following error below
So my question is, how am I getting the error that the file doesn't exist if It's 100% there? Thanks!
<?php
require_once '/public_html/domain/lib/swift_required.php';
?>
Warning: require_once(/public_html/domain/lib/swift_required.php) [function.require-once]: failed to open stream: No such file or directory in /home/myuser/public_html/domain/email.php on line 5
Fatal error: require_once() [function.require]: Failed opening required '/public_html/domain/lib/swift_required.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/myuser/public_html/domain/email.php on line 5
Here's a screenshot of my dir from FileZilla.
http://i.imgur.com/Zsy8y.jpg

This is wrong:
// this is absolute path, just like /home/user or /var/www
require_once '/public_html/domain/lib/swift_required.php';
Use instead:
// this is relative path to the current file
require_once 'public_html/domain/lib/swift_required.php'; //notice: no '/' in the beggining
OR:
// so use this one if you know the whole path to the file
require_once ABSOLUTE_PATH_TO . 'public_html/domain/lib/swift_required.php';
OR:
// or use this one if you don't know the whole path
// or if the path will change (dev machine and production machine)
require_once dirname(__FILE__) . RELATIVE_PATH_TO . 'public_html/domain/lib/swift_required.php';

Related

my other require once php page gets error when i call it in index

I get this error when I try to call product_class.php in index.php. My product_class.php works fine, but when I try to add it to index this error show up:
Warning: require_once(../Includes/config/general.php): failed to open stream: No such file or directory in D:\Programming\Web\xampp\htdocs\android-api\product\product_class.php on line 2
Fatal error: require_once(): Failed opening required '../Includes/config/general.php' (include_path='D:\Programming\Web\xampp\php\PEAR') in D:\Programming\Web\xampp\htdocs\android-api\product\product_class.php on line 2
here my code at index.php
<?php
require_once('product/product_class.php');
require_once('Includes/config/general.php');
require_once INCLUDES_DIR.'/database.php';
?>
Make sure you specify the correct file path. If the index.php file and the product or Includes folder are in the same folder, try this:
require_once __DIR__ . '/product/product_class.php';
require_once __DIR__ . '/Includes/config/general.php';

include path is not working when referencing another file

I'm having problem with include() and require_once() this is what I have on my script on report-publisher file that resides here :
C:\xampp\htdocs\checklists\reports\report-publishers.php
now i want to include this file:
<?php include("images/report-publisher-completed.php");?>
and the directory of that script is here:
C:\xampp\htdocs\checklists\reports\images\report-publisher-completed.php
it works the problem is in this report-publisher-completed.php i have the following:
require_once("../../includes/database.php");
here is the location of that file: C:\xampp\htdocs\checklists\includes\database.php
so when i run the code I get the following error:
( ! ) Warning: require_once(../../includes/database.php): failed to
open stream: No such file or directory in
C:\xampp\htdocs\checklists\reports\images\report-publisher-completed.php
on line 3
( ! ) Fatal error: require_once(): Failed opening required
'../../includes/database.php' (include_path='C:\xampp\php\PEAR') in
C:\xampp\htdocs\checklists\reports\images\report-publisher-completed.php
on line 3
How can I fix this issue?
Thanks!
Try like this
require_once(dirname(__FILE__).'/../../includes/database.php');
The safer way to include a file is to use a relative path from the current script, using the constant __dir__, like this :
include __dir__ . '/includes/database.php';
So, for your case, probably :
include __dir__ . '/../../includes/database.php';
Try this
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/database.php";
Instead of
require_once("../../includes/database.php");

trouble with require_once failed to open stream: No such file or directory

I'm getting the following error when trying to open the index file of a project that I am taking over on:
Warning: require_once(core_services/logging.php): failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/app/docroot/www.website.com/index.php on line 7
Fatal error: require_once(): Failed opening required 'core_services/logging.php' (include_path='.:/Applications/XAMPP/xamppfiles/lib/php') in /Applications/XAMPP/xamppfiles/htdocs/app/docroot/www.website.com/index.php on line 7
The code the error refers to looks like this:
7 require_once "core_services/logging.php";
8 $logger=new syslog_class(__FILE__,LOG_DEBUG);
I checked to make sure the filepath exists by defining it and echoing it back as well as the contents of logging.phpin terminal and that returns just fine and when I get the current working directory on line 6, it returns /Applications/XAMPP/xamppfiles/htdocs/app/docroot/www.website.com, which I am assuming is defining my root folder.
Not sure exactly how to go about resolving this problem and if anyone has any ideas on approach, I would love to hear them as my PHP is a bit rusty and lacking outside of the context of wordpress.
edit: approaches I've tried so far
require 'core_services/logging.php';
require '/core_services/logging.php';
require './core_services/logging.php';
require '../core_services/logging.php';
require '/Applications/XAMPP/xamppfiles/htdocs/app/docroot/www.website.com/core_services/logging.php';
require realpath(dirname(__FILE__)) .'/core_services/logging.php';
require(__DIR__"/../core_services/logging.php");
require_once 'core_services/logging.php';
require_once '/core_services/logging.php';
require_once './core_services/logging.php';
require_once '../core_services/logging.php';
require_once '/Applications/XAMPP/xamppfiles/htdocs/app/docroot/www.website.com/core_services/logging.php';
require_once realpath(dirname(__FILE__)) .'/core_services/logging.php';
require_once __DIR__"/../core_services/logging.php";
I have also verified that it is not a permissions issue.
Try specifying full path:
require './core_services/logging.php';
//OR
require '/Applications/XAMPP/xamppfiles/htdocs/app/docroot/www.website.com/core_services/logging.php';

require_once function error when creating webpage in new folder

I am running wamp64 to locally host my website (it is a vbulletin forums used for testing if that helps at all).
I am trying to create a new webpage that is located in a subfolder instead of the root of the website, however I am running into errors.
The webpage I am trying to create is the index.php webpage inside of the addons folder.
My file structure is:
C:
-wamp64
--www (website root)
--global.php
---addons
----index.php
----images
---includes
----config.php
The code I am using for addons - index.php is:
<?php
error_reporting(E_ALL & ~E_NOTICE);
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'addons');
$phrasegroups = array();
$specialtemplates = array();
$globaltemplates = array(
'ADDONSTESTPAGE'
);
$actiontemplates = array();
require_once('/../global.php');
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('ADDONSTESTPAGE') . '");');
?>
When I create a new page in the www folder, it works perfectly (except I use require_once('/global.php'); instead of require_once('/../global.php');.
However, because this is in a subfolder, I am running into the following error due to the files that the global.php is requiring once having their own require_once functions inside of them and those files have their own require_once functions inside of them, etc.
Here is the error I am getting now when I go to localhost/addons/:
Warning: require_once(C:\wamp64\www\addons/includes/init.php): failed
to open stream: No such file or directory in C:\wamp64\www\global.php
on line 20
Fatal error: require_once(): Failed opening required
'C:\wamp64\www\addons/includes/init.php'
(include_path='.;C:\php\pear') in C:\wamp64\www\global.php on line 20
Here are lines 13-20 of global.php:
// identify where we are
define('VB_AREA', 'Forum');
define('CWD', (($getcwd = getcwd()) ? $getcwd : '.'));
// #############################################################################
// Start initialisation
require_once(CWD . '/includes/init.php');
How do I solve this without messing up other files that use the global.php file? I have heard realpath is a common solution for this, but I am new to php and not exactly sure how to use it in this scenario.
All help is appreciated, thank you very much, if you need any more information feel free to ask!
Okay I was able to solve that error by changing require_once(CWD . '/includes/init.php'); to require_once(__DIR__ . '/includes/init.php');.
Now I am getting this error:
Warning: require_once(C:\wamp64\www\addons/includes/class_core.php): failed to open stream: No such file or directory in C:\wamp64\www\includes\init.php on line 51
Fatal error: require_once(): Failed opening required 'C:\wamp64\www\addons/includes/class_core.php' (include_path='.;C:\php\pear') in C:\wamp64\www\includes\init.php on line 51
Class_core.php exists in the includes folder.
Line 51 of init.php is:
require_once(CWD . '/includes/class_core.php');
I tried changing it to require_once(__DIR__ . '/includes/class_core.php'); but it breaks the entire website.
global.php assumes the server process is running from the main C:/wamp64/www directory but because you are running from the addon folder, CWD will be set to C:/wamp64/www/addon , hence all the errors.
To resolve this, do, in your index.php
1) Revert all the changes you have made to VBulletin in your global.php and init.php etc...
2) set your current working directory to the root directory, you can use chdir('../') at the top of index.php before any require_once
3) require global.php in your index.php require_once('global.php');
Step 2 works because now php now sees the root directory as the working directory.

PHP include path error

I keep getting an error when I try to include simpletest in my include_path:
<?
set_include_path(get_include_path() . PATH_SEPARATOR . realpath(basename(dirname(__FILE__)) . '/../../'));
include 'simpletest/autorun.php';
returns:
.:/usr/lib/php:/Users/kristiannissen/Documents/php
Warning: require_once(/Users/kristiannissen/Documents/php/simpletest/arguments.php): failed to open stream: No such file or directory in /Users/kristiannissen/Documents/php/simpletest/reporter.php on line 13
Fatal error: require_once(): Failed opening required '/Users/kristiannissen/Documents/php/simpletest/arguments.php' (include_path='.:/usr/lib/php:/Users/kristiannissen/Documents/php') in /Users/kristiannissen/Documents/php/simpletest/reporter.php on line 13
personally your view pages are the first executed, such as index.php and view pages should always be in the root of your html.
so within index.php you can do:
define("BASE_PATH",str_replace("\\","/",dirname(__FILE__)));
so now BASE_PATH would be equal to: /Users/kristiannissen/Documents/php/simpletest
So if you want to phpdirectory in your include path you should use dirname() to go UP a directory:
//Get an array of your include paths
$include_parts = explode(PATH_SEPARATOR,get_include_path());
//Extend the paths
$include_parts[] = dirname(dirname(BASE_PATH)); //this is ../../
//recompile the paths and set them
set_include_path(implode(PATH_SEPARATOR,$include_parts));
this is the safe way to accomplish what your trying to do.
There is an alpha2-release on sourceforge that has the arguments.php-require commented out. I guess it isn't needed anymore.

Categories