I'm learning php and mySQL for the first time (using Welling/Thomson) and I'm using my mac as the server. In doing so I'm turning on web sharing and accessing it through something like http://192.168.0.103/~myname/ or localhost/~myname/. I'm able to run basic PHP scripts. I set up everything using this guide. I have each example divided into the chapters: to get to the chapter 1 projects I go through localhost/~myname/book/Chapter02/example.html in my browser. These files are actually stored in /Users/myname/Sites/book/Chapter02/example.html
I'm attempting to do file openings and get the following error:
Warning: fopen(/Library/WebServer/Documents/../orders/orders.txt): failed to open stream: No such file or directory in /Users/myname/Sites/book/Chapter02/processorder.php on line 72
I first thought that it was because the directory and the fopen were different, so instead of storing my files in localhost/~myname/, I tried localhost/public_html/ Storing them there is actually /Library/WebServer/Documents/public_html/ on my computer. I still get the error:
Warning: fopen(/Library/WebServer/Documents/../orders/orders.txt): failed to open stream: No such file or directory in /Library/WebServer/Documents/public_html/Chapter02/processorder.php on line 72
Then I looked it up online and saw that it had to do with permissions. I created a directory in /Library/WebServer/Documents/public_html/Chapter02/ called "orders" with read & write permissions from everyone through the terminal (done with chmod), but still I get the same error. I'm not sure where the problem is. If it is my server set-up, where are the files? Any help would be greatly appreciated.
Here is the php script if you think it will help http://pastebin.com/14gpim8e
I'm trying to be as clear as I can, but I'm sure this will need some clarification so feel free to ask if you need any more information.
Found the answer.
The problem came in 2 ways:
finding where the file was supposed to be, and
permissions.
In this case, it needed read/write permissions from everybody, and it needed to be in the /WebServer/ directory and no lower (as I had been doing in every single directory but the WebServer one. Seems kind of dumb now that I couldn't get it). Thank you all for your help.
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");
forgive me if is a basic question...
I am working on setting up a form on our new hosted Wordpress site - currently hosted inhouse on IIS/PHP/Wordpress server (I am not JR - but this stuff escapes me and would really like to figure it out!! I hate not knowing)
The OP that made the form / got it working is no longer around and I am sure there is a better way but this is what I have - a request form.
When I load the required files in the same path - copy the code from the WP page and paste it in the new Wordpress page - it loads without formating, the pick box doesnt look right and when I submit the form - I get these below PHP file errors. I can open the path in my browser and it exists - I see the class.GA_Parse.php file)
I checked execustion rights on the scripts - its set to execute - apart from that I dont know why it cant fine the files and that include_path I dont see via my hosting companys dir structure via FTP.
Any help would put me forever in your debt, I hope to be able to return the help, this site looks amazing!
Cheers,
Warning: require(/gaparser/class.GA_Parse.php): failed to open stream: No such file or directory in /home/comany/public_html/stage/forms/getfreetrial_v3.php on line 4
Warning: require(/gaparser/class.GA_Parse.php): failed to open stream: No such file or directory in /home/company/public_html/stage/forms/getfreetrial_v3.php on line 4
Fatal error: require(): Failed opening required '/gaparser/class.GA_Parse.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/company/public_html/stage/forms/getfreetrial_v3.php on line 4
PHP will load pages based on the disk location, not the URL. This means it's starting in the server's root / directory, not in /home/company/public_html/stage/forms. When including a file, either you have to use a relative link:
require('./gaparser/class.GA_Parse.php'); // starts in the same directory as the file
Or use PHP's server variable to get the document root:
require($_SERVER['DOCUMENT_ROOT'].'/gaparser/class.GA_Parse.php');
The paths may need to be tweaked depending on where the file actually is.
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
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