Page 1 of 1
This error has stumped me...
Posted: Mon May 26, 2008 11:23 am
by rogdawg
I have been writing code for some time but, I am now writing PHP using the Eclipse PDT development environment, and the LAMP stack. I have some, but not much, experience with Linux and none with PHP or Eclipse.
I am trying to access a fairly simple login page I have copied (it is an example from the book "The PHP Anthology" from Sitepoint. com).
Here is the beginning of that page:
Code: Select all
<?php
error_reporting(E_ALL);
require_once 'HTML/QuickForm.php';
When I go to my browser and navigate to:
http://localhost/projname/login.php
I get this error:
Warning: require_once(HTML/QuickForm.php) [function.require-once]: failed to open stream: No such file or directory in /var/www/rentit/login.php on line 3
The words "function.require-once" are a hyper link to a page that reads:
Not Found
The requested URL /rentit/function.require-once was not found on this server.
Apache/2.2.4 (Ubuntu) PHP/5.2.3-1ubuntu6.3 Server at localhost Port 80
In the Eclipse project that contains the Login.php page, I have added an include path that points to "/usr/share/php/PEAR".
I have verified that /usr/share/php/PEAR/HTML/QuickForm.php exists so, I don't understand why the error is occurring.
(Also, I have verified that simple HTML pages, and PHP test pages work on my localhost so, php and Apache2 seem to be working nicely)
Thanks in advance for any advice you can give.
Re: This error has stumped me...
Posted: Mon May 26, 2008 1:27 pm
by impulse()
Permissions problem? Try running 'chmod 777 QuickForm.php' and then retry.
Re: This error has stumped me...
Posted: Mon May 26, 2008 2:41 pm
by califdon
The problem isn't with accessing the include file, it's what's IN the include file:
I get this error:
Warning: require_once(HTML/QuickForm.php) [function.require-once]: failed to open stream: No such file or directory in /var/www/rentit/login.php on line 3
That says that line 3 of the QuickForm.php script is trying to open login.php in your /var/www/rentit/ directory, and it probably isn't there.
Re: This error has stumped me...
Posted: Mon May 26, 2008 4:41 pm
by rogdawg
login.php is in the correct location (var/www/rentit/login.php).
I logged in as root and changed the permissions on QuickForm.php and that has not changed anything either.
I am stumped. This should be a simple thing. I have done some basic thing incorrectly somewhere but, I can't figure it out.
Thanks for your suggestions. Any additional suggestions would be appreciated.
Re: This error has stumped me...
Posted: Mon May 26, 2008 4:53 pm
by Zoxive
Where is quickform.php?
From your code you are trying to include it from /var/www/rentit/HTML/QuickForm.php
Re: This error has stumped me...
Posted: Mon May 26, 2008 6:01 pm
by pickle
califdon wrote:The problem isn't with accessing the include file, it's what's IN the include file:
I get this error:
Warning: require_once(HTML/QuickForm.php) [function.require-once]: failed to open stream: No such file or directory in /var/www/rentit/login.php on line 3
That says that line 3 of the QuickForm.php script is trying to open login.php in your /var/www/rentit/ directory, and it probably isn't there.
Other way around. login.php is trying to include 'HTML/QuickForm.php' and it isn't there.
~rogdawg: You said you added an include path in your Eclipse project. I don't know if there's a setting in Eclipse that makes it automatically change the include path for each page - but judging by the code you posted, it does not.
Before your "require_once()" call, add this:
Code: Select all
ini_set("include_path", "/usr/share/php/PEAR/");
That should update your include path & make PHP look at /usr/share/php/PEAR/HTML/QuickForm.php.
Also, inside your
Code: Select all
tags, replace "text" with "php" & your PHP code will be syntax highlighted properly.
Re: This error has stumped me...
Posted: Mon May 26, 2008 7:21 pm
by califdon
pickle wrote:califdon wrote:That says that line 3 of the QuickForm.php script is trying to open login.php in your /var/www/rentit/ directory, and it probably isn't there.
Other way around. login.php is trying to include 'HTML/QuickForm.php' and it isn't there.
Doh! How embarrassingly correct you are. What was I looking at?? Thanks, pickle.
Re: This error has stumped me...
Posted: Mon May 26, 2008 9:16 pm
by rogdawg
OK. The ini_set() suggestion has helped. When I put that line of code in, I got the same error again but, pointing to a line in the QuickForm.php file that is in the PEAR directory. The error stated that the PEAR.php file could not be found (QuickForm.php contains a line reading "require_once 'PEAR.php';"). I put a similar ini_set() statement in QuickForm.php, pointing to the directory of the PEAR.php file, and that solved that. Now I am getting an error stating that HTML/Common.php cannot be found from the same QuickForm.php file. That is because HTML/Common.php has not been installed. So, that is understandable.
Geez.
I assume that adding these lines of code to files such as QuickForm.php is probably not a good idea.
So, I am seriously considering striking all of my PHP and PEAR installations and starting from scratch again. I clear have installed this stuff incorrectly 'cause that paths are all messed up. So, it might be best, I think, if I start fresh again, now that I have learned a little bit about how this is supposed to work.
I have a lot to think about. I hate starting again but, I don't know how workable this mess I have made is going to be.
Thanks again for all your help. I was completely stumped.
Re: This error has stumped me...
Posted: Tue May 27, 2008 9:42 am
by pickle
Rather than starting over, just modify your include path in php.ini . That will essentially have the same effect as putting that ini_set() line at the top of every PHP page - which should solve your problem.
Re: This error has stumped me...
Posted: Tue May 27, 2008 5:45 pm
by rogdawg
Yes, I would much rather do that but...I have made such a mess of my directories that I have created a problem. In my attempts to get the right packages and set things up in different ways, while I was trying to solve this error, I have gotten several php.ini files on my machine now. In all, I have nine files that have "php.ini" in their title. They are:
/usr/share/doc/php5-common/examples/php.ini-paranoid
/usr/share/doc/php5-common/examples/php.ini-dist
/usr/share/doc/php5-common/examples/php.ini-recommended
/usr/share/php5/php.ini-dist
/usr/lib/eclipse/plugins/org.zend.php.debug.debugger.linux.x86_5.2.12.v20071210/resources/php4/php.ini
/usr/lib/eclipse/plugins/org.zend.php.debug.debugger.linux.x86_5.2.12.v20071210/resources/php5/php.ini
/etc/php5/apache2/php.ini
/etc/php5/cgi/php.ini
/etc/php5/cli/php.ini
So, I am not sure which one to edit. And, I know it can't be a good thing to have all these files scattered all over. I will start with the php.ini located at /etc/php5/apache2/php.ini and see what effect that has when I change the variable. I think I will do some testing to see which files are needed and which files can be eliminated.
Thanks for all your help with this. My first experience with this forum has definitely been a positive one. You have been very helpful.
Thanks again.
Re: This error has stumped me...
Posted: Tue May 27, 2008 5:50 pm
by pickle
Only "php.ini" files are every referenced by PHP. Any of the "php.ini.paranoid", etc files templates for example setups - like paranoid, recommended, etc. You don't need to touch them.
If you want to find out which php.ini file to edit, make a phpinfo() page - that'll tell you which php.ini file PHP is referencing.
Re: This error has stumped me...
Posted: Tue May 27, 2008 7:18 pm
by rogdawg
Thanks for the tip!
Yes, it was the /etc/php5/apache2/php.ini file that needed to be edited.
Thanks very much.