I am running XAMPP on Win7 SP1 and I have encountered a problem.
I have a dir structure similar to this:
htdocs
_ head.php
runes
_ algiz.php
From inside of algiz.php I want to include the files head.php since I have a couple of includes in there like my style sheets, etc. If I run a file in the root that includes the head.php I have no issues.
However, if I try to run the algiz.php I get an error when it tries to access head.php. I am using require "../head.php";
When I try this I get the following errors.
Warning: require(head.php): Failed to open stream: No such file or directory in E:\XAMPP\htdocs\runes\algiz.php on line 3
Fatal error: Uncaught Error: Failed opening required 'head.php' (include_path='E:\XAMPP\php\PEAR') in E:\XAMPP\htdocs\runes\algiz.php:3 Stack trace: #0 {main} thrown in E:\XAMPP\htdocs\runes\algiz.php on line 3
I even tried to visit the dir htdocs/runes from my browser and I saw algiz.php listed. Then I clicked on the algiz.php and got the same errors.
EDIT: I thought that it may not be clear, but the runes dir is a sub in the htdocs folder.....
So, any insight or suggestions are greatly appreciated.
Jim
I saw the require(head.php) also... Not sure why it is showing that.
Just for the hell of it, opened the file in M$ Office and set show nonprintable characters. Only thing that showed was the paragraph mark at the end of the line.
Deleted the file off of my server. But, reloaded the local file and retyped the line anyway, same issue.
Opened the file using my FTP and retyped the line using Notepad, same.
Opened my site locally using XAMPP, same issue.
There are two things driving me completely nuts. One is the error message. Two is not being able to figure this out...
EDIT: I don't think this should make a difference, but I am using PHP version 8.0.15
Your warning only says require(head.php) not require(../head.php)
Are you sure you're actually using require "../head.php ?
Maybe you got some weird character in there? Try rewriting the line, just to be safe.
Related
I generally work with WAMP but for some reason had to switch over to XAMPP.
Ran into this really weird problem. When i try to read a file using file_get_contents i get an error saying that the file/dir does not exist EVEN THOUGH IT DOES.
Even if something as simple as
file_get_contents('x.txt');
throws an error
Warning: file_get_contents(x.txt): failed to open stream: No such file or directory in C:\xampp\htdocs\cryy\index.php on line 3
And yes, i've tried using the magic constant
__DIR__
to no avail.
I'm using XAMPP 3.2.2 and PHP 7.0.18, running on Windows 10.
I hope someone can help me figure this out.
Try providing full path of the you want to get content. If you want to access file from root of the folder, then you can use
file_get_contents($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."project_folder".DIRECTORY_SEPARATOR."filename.txt");
OR
file_get_contents(__DIR__.DIRECTORY_SEPARATOR."filename.txt");
I am in the process of moving a PHP website from a shared hosting server to a DigitalOcean server. I have come across an issue that I'm not sure how to debug.
There is a page that has a log-in form with action=2/login.php. This form is located in /var/www/html/calendar.php (it is a Ubuntu 14.04 DO droplet). When submitting the form, there is a 500 Internal Server Error. I've found the error in question but I am not sure how to debug it (because it runs fine on the other server).
/var/www/html/2/login.php
<?php
require_once('../db_connect.php');
...
db_connect.php is located at /var/www/html/db_connect.php
When I $php 2/login.php I get the following error:
login_error.txt
PHP Warning: require_once(../db_connect.php): failed to open stream: No such file or directory in /var/www/html/2/login.php on line 4
PHP Fatal error: require_once(): Failed opening required '../db_connect.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/html/2/login.php on line 4
When I run $php login.php when in directory /var/www/html/2 it works fine (which I guess makes sense, as ../db_connect.php is a relative path).
I want to know why it is working on the other server and not the DO server?
The php.ini is the same (which could be a problem), but on Server #1 (Verve), it is shared hosting, so our root is /home/[username]/public_html and on the new server is is /var/www/html.
I can link to the live sites in question if necessary (but would prefer not to). The /var/www/html/2/login.php and the /var/www/html/calendar.php scripts are exactly the same, and while I understand this will definitely cause issues later as the absolute path to the root of the web application is different, I don't know what would be causing this specific issue.
I have also looked at this question which is very similar: PHP require_once resetting to current working directory. However, this code works on the other server, and not here, so I think there is something more than just a lack of a relative file path, and I would prefer to find the solution that explains why the script isn't working rather than patching the script, as I'm pretty sure I'd have to change every single other script that uses require_once('../db_connect.php') as well.
Thanks for any help!
Did you try using __DIR__?
require_once(__DIR__ . '../db_connect.php');
All of a sudden, my SMF powered forum has stopped working.
In fact, PHP files no longer seem to want to open on my website. I tried uploading a blank PHP file with just a few characters of text, and it refuses to open giving the error below.
I also tried a PHPinfo file, which didnt work, giving the same error. Other sites on the same server are working.
Fatal error: Unknown: Failed opening required '/home/users/a/n/mysite/www/index1.php' (include_path='.') in Unknown on line 0
Any ideas about whats gone wrong?
Just an idea. As it happens to all php files that could to what i know only mean 2 things.
Either there is somekind of error on the php extension.
OR what it most likely is, is that SMF uses a .htaccess to make user friendly links. Which means all requests to the server no matter what (Unless specified in the .htaccess) will be sent to index.php and then be handled.
So if there is a error in the index.php or the library of some sort it would explain why no matter what php file you're looking at it gives the error.
-
One thing you could do is to take a backup of all your images in the system. Then try to install a fresh version on your local machine. Once done copy/past the images back and copy all the current php files for SMF and replace the current ones on your host with them.
-
Haven't used SMF much so I'm not sure this is the solution at all. But to me it sounds like a solution.
It seems you have broken your root document.
do chmod 755 index1.php
and it should solve the problem.
You should check the php.ini or php5.ini file. I don't believe the single ticks around '.' for the include_path are valid. Double quotes will work however.
It seems you have been hacked:
http://wordpress.org/support/topic/fatal-error-unknown-failed-opening-required-google_verifyphp
Ahh sorry reread the question. I guess this is what you may try.
Check your file permissions. by default if your web server can not read files thats what you are going to get. I could be wrong but worth having a look
so just chmod your root folder to say 755 atleast
Total newbie here, so take it as you will...
I'm doing a site upgrade right now, and everything works fine except...
I have a WordPress installation in a subdirectory, and now that I've brought the main site live, I'm getting
include(/settings.php) [function.include]: failed to open stream: No such file or directory
and
include() [function.include]: Failed opening '/settings.php' for inclusion (include_path='.:')
on includes from within the subdirectory. I've played with setting different include_path settings, I know for sure the files are there (they are being included with no problems from the root directory), and I'm changed no permissions or anything during the rollout of the site.
Please let me know if this question is improper, or misplaced, or too vague, or what have you - first post after months of googling and lurking.
thanks in advance!
You're likely using php in a chrooted environment, so the root path of the server doesnt match that of the script.
Regarding the variables scope issue, could you post some sample code?
"/settings.php" points to the root of your server. It should be "settings.php" if it is on the same path and it should be in quotes.
Cheers
I would recommend adding define('WP_DEBUG', true); to your wp-config.php file and report back with more information. Make sure to undo this any you grab the info for debugging as having this on a live site could be a security risk. I just search my whole WP directory for include( "/settings.php" ); and could not find anything, which makes me think that it make be an issue with a plugin, theme, or other custom code. You could troubleshoot this by disabling all of your plugins, seeing if the site works again, and then painstakingly enabling your plugins individually until you find the culprit.
Does the error message you get point to a specific file and line number? That can help debug the problem.
I'm trying to set up my Flex Builder 4 dev environment, up to and including PHP and the ZendFramework on a WAMP stack on my hard drive.
Everything goes swimmingly until I try to set up a data service. I point it to the php class file, it populates the various fields in the form so I know it understood it, and I press next. After a little bit of tweaking I have the ZendFramework installed and everything seems to be pointing the right way, so I'm not sure why I'm getting this error:
"Make sure that Zend Framework is installed correctly and the parameter "amf.production" is not set to true in the amf_config.ini file located in the project output folder.
Warning: include_once(C:\wamp\www\TestDrive-debug\EmployeeService.php) [function.include-once]: failed to open stream: Permission denied in C:\wamp\ZendFramework\library\Zend\Loader.php on line 146"
What could be causing a permissions error like that? It's not on the system level because I went into properties and fully opened that file up so even a basic user has full permissions - still no dice.
I'm not reeeally a PHP guy so this is a bit beyond my skillset. Has anyone encountered this problem before? I'm just following the tutorial I have here and it SHOULD work. I'm just not clear on what would be causing a permissions issue like this.
Thanks!
I resolved this problem by changing the encoding of the php file. There must be some invisible characters in the file that were screwing up the parsing. Try saving the php service file with different encoding and see if it works for you. The one that worked for me was created by eclipse. I copy pasted the code in it, saved, and boom it worked!
just had same issue and resolved same as OP, just resave file with notepad, funny deal, but it happens
inside the folder of amf_Config.ini , create a new file amf_config2.ini , copy the contents of amf_config.ini as it is into amf_config2.ini , now inside amf_config2 double quote the value of parameter webroot (webroot="xxxxx") save ur amf_config2 , open gateway.php which would be also inside the same dir , change $configfile = "$dir/amf_config.ini" to
$configfile = "$dir/amf_config2.ini" , save it and try