I am trying to upgrade my php from v.5 to v.7.2, and I have encountered this bug I couldn't fix.
I have a tpl file with external header & footer included but they wont load anymore.
This is the error( * please note: spaces added on purpose * ) :
Warning: include(): Failed opening 'https: //mywebsite.com/folder1/includes/wrappers/footer.html' for inclusion (include_path='.;C:\php\pear') in * folderpath*\bottom_page.html on line 86
At the main tpl file (lets call it "home.tpl") I have this line for the footer:
<?php include dirname( __ FILE__)."\bottom_page.html" ; ?>
At bottom_page.html I have some scripts which seems to be fine and at the end, this line:
<?php include('https: //mywebsite.com/folder1/includes/wrappers/footer.html'); ?>
this line seems to be the problem, I searched a lot and did not find a solution
This is what I have tried:
verify allow_url_fopen & allow_url_include in php.ini is 1
using readfile or file_get_contents instead of include
Any more suggestions? :)
p.s: the url is correct, the browser shows the content I wanted to include..
Ok so I have found a solution- finally:
php include to external url
the comment from Nicholas Valbusa, the curl usage works :)
Related
I'm getting a rather frustrating warning which is blocking me from further development.
I've tried using require_once / include_once for a file with a relative path, and it seems to be unable to find it. Then all of a sudden it works, and now it doesn't work.
What could be causing this problem?
Detailed screenshot of my file and paths:
Notice that line 3 works, but line 4 doesn't work.
Warning I'm getting client side:
Thanks.
Update with a screenshot of my finder:
I am having the same problem on the Windows-with-xampp side of the fence as Gerardo Tarragona is having on the Ubuntu-with-lampp side. Ref: How to install phpChart lite library?
I have tried a couple or few things and the roadblock I am hitting (see PHP error messages from browser below the code snippet) seems to be that the conf.php file is trying to require_once('phpChart.php') but I cannot find this file phpChart.php anywhere on disk. It does not seem to be with the phpChart_Lite extracted download. Can anybody shed light on this ? What am I missing ?
Here is the conf.php file code:
<?php
define('SCRIPTPATH','/phpChart_Lite/');
define('DEBUG', true);
/******** DO NOT MODIFY ***********/
require_once('phpChart.php');
/**********************************/
?>
Warning: require_once(phpChart.php): failed to open stream: No such file or directory in C:\xampp\htdocs\phpChart_Lite\conf.php on line 10
Fatal error: require_once(): Failed opening required 'phpChart.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\phpChart_Lite\conf.php on line 10
Depending on your system, change SCRIPTPATH to
define('SCRIPTPATH','/phpChart_Lite');
or
define('SCRIPTPATH','phpChart_Lite/');
I have been trying to import/include file in my php script file and somehow it is not working. I know this require_once question has been asked so many times [ 1. require_once with subfolders , 2. require_once() cant find the include path, 3. Using require_once for up directory not working] but none of them seemed to be working for me.
Blow picture will explain what I am trying to do clearly:
What I tried and errors:
Attempt 1
require_once(__DIR__.'GoogleClientApi/src/Google/Service/Analytics.php');
echo 'Hey1'; //Does not echo this, means something went wrong above.
require_once(__DIR__.'GoogleClientApi/src/Google/Client.php');
echo 'Hey2';
Error I get:
Attempt 2 (Fixed issue of attempt 1 but raised another issue.)
So I decided to use absolute path :
include '/Applications/MAMP/htdocs/GoogleClientApi/src/Google/Client.php';
echo 'Hey1';
include '/Applications/MAMP/htdocs/GoogleClientApi/src/Google/Service/Analytics.php';
echo 'Hey2';
Gives me error in Client.php file:
`Warning: require_once(/Google/Auth/AssertionCredentials.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/GoogleClientApi/src/Google/Client.php on line 18`
`Fatal error: require_once(): Failed opening required '/Google/Auth/AssertionCredentials.php' (include_path='.:/Applications/MAMP/bin/php/php5.5.10/lib/php') in /Applications/MAMP/htdocs/GoogleClientApi/src/Google/Client.php on line 18`
Investigating upon I found Client.php (of Google APIs Client Library for PHP) has these lines which are actually present:
require_once 'Google/Auth/AssertionCredentials.php'; // <-- Can't find
require_once 'Google/Cache/File.php'; // <-- Can't find
require_once 'Google/Cache/Memcache.php'; // <-- Can't find
I do not what is going wrong here. Fixed attempt 1's issue but now errors are in google's own library which I do not know how to overcome. I assume I am doing something silly which I can not figure out. Any help or suggestion will be appreciated.
Did you ever dumped __DIR__? Usually there's no / at the end. So you would have to change your code to this:
require_once(__DIR__.'/GoogleClientApi/src/Google/Service/Analytics.php');
^
I just checked in your screen shot with the error message, there's no / at the end.
/Applications/MAMP/htdocsGoogleClientApi/src/Google/Client.php
instead of /Applications/MAMP/htdocs/GoogleClientApi/src/Google/Client.php
It turns out I had to set the include path to include the root directory (src folder) using this line :
set_include_path("/Applications/MAMP/htdocs/GoogleClientApi/src/");
This worked for me in Client.php
set_include_path(__DIR__.'/../' . PATH_SEPARATOR . get_include_path());
Okay.
So on line 37 on this script http://ideone.com/grapQ the include_once command is basically just being ignored and the content I am trying to show is not showing up at all, not even a error message.
I tried enabled error reporting and not one a single error is being shown.
Also i tried using Echo and the same issue persist.
Does anyone have any ideas on why its being ignored and not even a error message is being shown? More than luck just its just something basic!
You are missing a semi-colon on the end of that include statement:
include_once('http://outside-resources.ultimatesphider.com/us-resources/2.0.1/2.0.1announce.php');
Additionally, when I tested it (just that line) here on my local machine, I got the following errors:
Warning: include_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /var/www/test.php on line 5
Warning: include_once(http://outside-resources.ultimatesphider.com/us-resources/2.0.1/2.0.1announce.php): failed to open stream: no suitable wrapper could be found in /var/www/test.php on line 5
Warning: include_once(): Failed opening 'http://outside-resources.ultimatesphider.com/us-resources/2.0.1/2.0.1announce.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/test.php on line 5
Deepak's answer has more information on allowing external files that probably applies to your question.
You cannot include remote files as it is in PHP 5.2.0 and later versions. If you want to use remote URL allow_url_include must be enabled for these. Refer Link
follow the link
http://php.net/manual/en/function.include-once.php
I am writing a web page that uses some php files. The php isn't working properly and I am trying to debug for things such as printing variables. I am new to php so this is all new territory.
I use firebug for other debugging and css alignment so I thought firephp might be a good way to begin.
I added firePHP into firefox and then following some tutorials I found I added this to my php file:
<?PHP
/* comment here down to line 15 */
require_once('FirePHPCore/FirePHP.class.PHP');
$firephp = FirePHP::getInstance(true);
The result I get when I load my page is:
Warning: require_once(FirePHPCore/FirePHP.class.PHP): failed to open stream: No such file or directory in /var/www/contactform.php on line 15 Fatal error: require_once(): Failed opening required 'FirePHPCore/FirePHP.class.PHP' (include_path='.:/usr/share/php') in /var/www/contactform.php on line 15
It seems like some more setup and library loading is required, but I am not sure what or how?
I am developing on Ubuntu using apache and /var/www/ as my local server.
Description: Ubuntu 11.04
Release: 11.04
Codename: natty
Advice on how to get past this error?
You need to add the "FirePHPCore" folder to the same directory that this code is being run in
require_once('FirePHPCore/FirePHP.class.php');
The file extension (.php) is NOT SUPPOSED TO BE CAPITALIZED.